thecodingcompany
DSA Pattern

Two Pointers & Sliding Window

Turn O(n²) scans into a single pass.

Problems4
FocusPattern + approach

4 problems

Attempt each problem before reading the approach. In the interview, state the pattern and complexity out loud first — that is what earns the marks.

01Valid PalindromeEasyTwo Pointers
ProblemDetermine whether a string is a palindrome considering only alphanumeric characters, ignoring case.
Approach. Move a left and right pointer inward, skipping non-alphanumerics and comparing lowercased characters.
02Longest Substring Without Repeating CharactersMediumSliding Window
ProblemFind the length of the longest substring with all distinct characters.
Approach. Sliding window with a map of last-seen indices; when a repeat appears, jump the left boundary past it.
03Container With Most WaterMediumTwo Pointers
ProblemGiven heights, find two lines that together with the x-axis hold the most water.
Approach. Start at both ends and always move the shorter side inward, tracking the best area.
04Three SumMediumTwo Pointers
ProblemReturn all unique triplets that sum to zero.
Approach. Sort, then fix one element and run a two-pointer scan for the remaining pair, skipping duplicates.

Practise here. Get placed there.

Prep+ is unlimited practice. When you are ready to turn it into an offer, TCC Placement Partner handles portfolio, resume and interviews.