All topics
5 patterns · 25 problems

Strings

Two pointers, sliding windows, hashmaps, and pattern matching applied to characters and substrings.

01Pattern

Two Pointers

Converge from both ends to compare characters without extra space.

This patternO(n)naïve O(n²)

When to reach for it

  • Utilize two pointers when the problem involves searching for pairs or triplets of characters within a string that satisfy specific conditions, particularly in sorted strings or when the order matters.

Spot it in the prompt

Look for problem descriptions mentioning the need to compare characters from both ends of the string or to traverse the string simultaneously with two pointers. Phrases like 'pair of characters,' 'triplet of characters,' or 'sorted string' indicate the potential application of two pointers.

Easy

Valid Palindrome

LeetCode
Loading animation…

How to solve it

Animation: Two Pointers technique

Set pointers at both ends, skip non-alphanumeric characters, and compare mirrored letters case-insensitively until the pointers cross.

Open full solution

Practice · 5 problems

Select any problem to watch the technique run. marks a problem with its own bespoke animation.

02Pattern

Sliding Window

A stretchy window scans substrings in one linear pass.

This patternO(n)naïve O(n²)

When to reach for it

  • Apply the sliding window technique when you need to find a contiguous substring within the string with specific properties (e.g., maximum sum, minimum size, longest length) and you can adjust the window size dynamically as you traverse the string.

Spot it in the prompt

Problems involving contiguous substrings often hint at the use of the sliding window technique. Look for phrases like 'substring,' 'contiguous characters,' 'sliding window,' or hints that a window needs to slide through the string.

Hard

Minimum Window Substring

LeetCode
Loading animation…

How to solve it

Animation: Sliding Window technique

Expand the right edge until all target counts are covered, then shrink the left edge to minimize the still-valid window.

Open full solution

Practice · 5 problems

Select any problem to watch the technique run. marks a problem with its own bespoke animation.

03Pattern

Hashmaps

Count and look up characters in constant time.

This patternO(n)

When to reach for it

  • Employ hashmaps when the problem involves frequency counting, grouping characters based on some property, or checking for the existence of certain characters in the string. Hashmaps offer efficient storage and retrieval of characters by keys.

Spot it in the prompt

Phrases like 'count,' 'frequency,' 'group,' or 'exist' suggest the potential use of hashmaps. Problems requiring counting occurrences, grouping similar characters, or checking for the presence of specific characters often indicate the application of hashmaps.

Medium

Group Anagrams

LeetCode
Loading animation…

How to solve it

Animation: Hashmaps technique

Use a sorted-character or frequency-count signature as the map key, bucketing every string that shares the same signature.

Open full solution

Practice · 5 problems

Select any problem to watch the technique run. marks a problem with its own bespoke animation.

04Pattern

String Manipulation

Reverse, parse, and rebuild strings character by character.

When to reach for it

  • Utilize string manipulation techniques when tasked with operations such as reversing, splitting, joining, or converting strings into different formats. These techniques are useful for parsing input, formatting output, or transforming strings according to specific rules.

Spot it in the prompt

Problem descriptions mentioning operations like 'manipulate,' 'convert,' 'parse,' or specific string operations (e.g., reversing, splitting) indicate the need for string manipulation techniques.

Easy

Reverse String

LeetCode
Loading animation…

How to solve it

Animation: String Manipulation technique

Swap characters from both ends inward, mutating the character array in place until the pointers meet.

Open full solution

Practice · 5 problems

Select any problem to watch the technique run. marks a problem with its own bespoke animation.

05Pattern

Regular Expressions

Match text against patterns with wildcards and DP.

This patternO(n·m)

When to reach for it

  • Apply regular expressions when the problem involves pattern matching or string validation based on specific rules, especially complex patterns or constraints. Regular expressions provide a powerful way to search, validate, and manipulate text efficiently.

Spot it in the prompt

Look for phrases like 'pattern,' 'validation,' 'matching,' or specific patterns (e.g., email addresses, phone numbers). Problems requiring validation of input strings against specific patterns or constraints often suggest the application of regular expressions.

Hard

Regular Expression Matching

LeetCode
Loading animation…

How to solve it

Animation: Regular Expressions technique

Fill a DP table over string and pattern indices, treating '*' as zero-or-more of its preceding element.

Open full solution

Practice · 5 problems

Select any problem to watch the technique run. marks a problem with its own bespoke animation.

You've got the patterns

Patterns get you through the screen. Shipping gets you hired.

FDE Coach is a cohort-based program in frontend, backend, AWS, and AI where you build real products and get referred to 200+ hiring partners. The free live workshop is the fastest way to see how we teach.

750+ engineers trained · frontend, backend, AWS & AI

August 15 · 0d left
Enroll Now