Inward — palindrome check
Compare mirrored characters from the two ends. If every pair matches, the string is a palindrome.
Problem · Is “RACECAR” a palindrome?
Comparison
Ready
Start from both ends
CompareCheck whether the characters at L and R are equal.
Move inwardWhen they match, move both pointers toward the center.
ResultIf L reaches R without a mismatch, the string is a palindrome.
Unidirectional — push zeros to the end
Fast scans the array. Slow marks the next position where a non-zero value should be placed.
Problem · Move all 0s to the end, preserving non-zero order
slow = next non-zero slot
Decision
Ready
Array: [0, 1, 0, 3, 12, 0, 5]
ZeroIf fast sees 0, only fast moves forward.
Non-zeroPlace the value at slow, then advance slow and fast.
ResultNon-zero values keep their relative order; zeros collect at the end.
Parallel — highest value across two arrays
Walk both arrays together, compare the current pair, and keep the highest value seen so far.
Problem · Find the highest value among both arrays
Comparison
Ready
Highest so far: —
Compare pairCompare A[i] with B[j].
Track maximumUpdate the highest value if the current pair contains something larger.
ResultAfter both pointers finish, the tracked value is the maximum across both arrays.