Slicing vs. Indexing (Mixing Two Strategies)
Notice what s.substring(i++, j--) does. It creates a brand-new, shorter string.
- If you take the word
"racecar"and chop off the first and last letters, your new string is"aceca". - In that new shorter string, what index is the first letter (
a) at? Is it at index1, or is it back at index0? - You are mixing two different recursive strategies here: string slicing (where the string gets smaller) and global index tracking (where the string stays the same size, but
iandjmove). If the string is getting smaller, do you actually needito keep increasing?