Skip to content

Reading from both ends

Read · 1 of 4

Compare the outside in

A palindrome reads the same backwards, like "level". Compare the first character with the last, the second with the second-last, and so on to the middle.

Position i pairs with position n − 1 − i. This "from both ends" idea is the two pointers pattern, one of the first in the DSA route.