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 index 1, or is it back at index 0?
  • 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 i and j move). If the string is getting smaller, do you actually need i to keep increasing?