Skip to content
FollowtheDamnCode

Strings

Character arrays with their own traps — building, counting, palindromes, matching, and parsing.

Big idea

Strings are sequences of characters, so most problems reuse array tools like two pointers, sliding windows, and frequency counts, with hashing or tries for heavier matching — building a string by repeated concatenation can quietly go quadratic.

Think of it like

A Scrabble player studying a rack of letter tiles is doing string work without realizing it. Checking whether the tiles can spell a word is a letter-count comparison, noticing that "listen" and "silent" use the same tiles is anagram detection, and scanning the board for a gap where a word fits is pattern matching. Strong players don't try every arrangement; they count letters, slide their eyes along a row, and use familiar prefixes to rule words in or out.

Spotting the technique

ClueTechniqueWhere
"anagram", "same letters", "can be formed from"count characterslesson 2
"palindrome"two ends inward, or expand from the centrelesson 3
"find the pattern in the text"matching, rolling hash, KMPlesson 4
"convert", "parse", "valid number"careful scanning with an indexlesson 5
"longest substring with/without…"sliding windowits own topic
"words sharing a prefix"trieits own topic