Complete the code to initialize the maximum palindrome length to 1.
let mut max_len = [1];The minimum palindrome length is 1 because a single character is always a palindrome.
Complete the code to expand around the center indices left and right.
while left >= 0 && right < s.len() && s.chars().nth(left) == s.chars().nth([1]) { left -= 1; right += 1; }
We compare characters at left and right indices to check palindrome expansion.
Fix the error in updating the start index after finding a longer palindrome.
if current_len > max_len { start = [1] + 1; max_len = current_len; }
After expanding, left is one step before the palindrome start, so we add 1.
Fill both blanks to correctly calculate the current palindrome length and update max_len.
let current_len = right [1] left [2] 1; if current_len > max_len { start = left + 1; max_len = current_len; }
The length is calculated by subtracting left from right and subtracting 1.
Fill all three blanks to return the longest palindromic substring correctly.
s[[1]..[2]].to_string() // returns substring from start to start + max_len // Use slicing with correct indices let result = &s[[1]..[2]];
The substring starts at 'start' and ends at 'start + max_len'.
