Skip to content

Reading from both ends

Read · 1 of 3

Compare the outside in

In Python s == s[::-1] checks a palindrome in one line. But the idea behind it matters for DSA: compare position i with position n − 1 − i, from the outside in.

Walking in from both ends is the two pointers pattern, one of the first in the DSA route.