- Diffuse from a starting point to both ends
- Palindrome substring can be either even or odd length
- Max length should be
k-j+1
, but whenj,k
exitwhile
,j--
,k++
would extend one step on both ends:k-j-1
would be the right length because of+2
difference. substring(start, end)
would be a start ofj+1
to justify the-1
1 | class Solution { |