SystemTutor
About
Sign in
Loading course documentation…
SystemTutor

COURSES

  • Data Structures & Algorithms
  • CSS MasterclassNew course
  • System DesignNew course

PRACTICE

  • Algorithm practice
  • CSS practice

LEGAL

  • Privacy Policy
  • Terms of Service
  • About

© 2026 SystemTutor. All rights reserved.

Built with 🫶 by Shatlyk

Course Overview
Algorithm Patterns OverviewFrequency CountersTwo SumValid AnagramGroup AnagramsFrequency Counters and Hash-Map LookupTwo PointersValid PalindromeTwo Sum IIContainer With Most WaterTwo-Pointer ReasoningSliding WindowMaximum Average Subarray ILongest Substring Without Repeating CharactersMinimum Size Subarray SumSliding-Window Reasoning
Algorithm Patterns

Algorithm Patterns Overview

Learn how frequency counters, two pointers, and sliding windows guide efficient solutions to common coding problems.

An algorithm pattern is a way of organizing work that applies to more than one problem. To choose a pattern, ask what information lets you safely skip work on the next step.

Choose a pattern

Start with one string, "ABBA". Counting letters gives the same answer even if the letters are rearranged. Checking for a palindrome requires comparing mirrored positions. Looking for adjacent repeats requires keeping a contiguous pair as it moves through AB, BB, and BA.

Three patterns applied to ABBA. A frequency counter records two As and two Bs, inward pointers compare the two outside As, and a width-two window captures the adjacent Bs.

Now apply those choices to other inputs:

ProblemWhat to keepWhy the next step is safe
Do two words contain the same letters in the same quantities?A count for each characterConsuming one count per letter accounts for every occurrence.
Which two values in a sorted array sum to a target?The two ends of the remaining rangeOrdering lets one comparison eliminate an entire endpoint.
Which consecutive four values have the largest sum?A running sum and window boundsNeighboring windows share three values, so only two edge values affect the update.

Some problems combine patterns. For example, a sliding window can use a map to track the character counts within its current bounds.

Chapter flow

Start with frequency counters, then move through two pointers and sliding windows:

  1. Frequency Counters: Count items with hash maps to avoid nested loops.
  2. Two Pointers: Use ordering or symmetry to decide which position can move.
  3. Sliding Window: Track a moving window over an array or string.

How is this lesson?

Previous lessonArrays, Strings & Hash Maps QuizNext lessonFrequency Counters
Edit on GitHubReport on GitHub
On this page
%

On this page

Choose a patternChapter flow