Strings
Learn what a string really is in memory and what each operation costs, then master the 9 string patterns — from two pointers to dynamic programming — through the interview questions asked most.
- 5 Lessons
- 26 Problems
- 60 Illustrations
What you will learn
- What a string is, how characters become bytes, and why length means different things in different languages
- Why strings are immutable in most languages, what s += c in a loop really costs, and how to build strings fast
- The everyday string operations in JavaScript, Python, Java and C++, and the time each one takes
- How to read a string question and pick the pattern that solves it
- 9 patterns from easiest to hardest: two pointers, frequency counting, scan and build, stack, sliding window, expand around the centre, backtracking, string matching and dynamic programming
- The string questions interviews ask most, each with a dry-run simulator
Why this course
Strings are the data you handle most: names, messages, URLs, code, DNA. They look simple until a question asks you to reverse one in place, count letters in a window, or match a pattern in linear time — and then the details matter.
The introduction is short but complete: what a string is, how it is stored as bytes, why most languages make it immutable, and what every common operation costs. Every later lesson builds on those details.
Then come 9 patterns, from easiest to hardest — each taught through the interview questions that use it, with code in four languages, the complexity of every approach and a simulator you can step through.
Requirements
- Comfort writing loops, conditionals and functions in at least one language
- The Arrays course helps: a string is an array of characters with a few extra rules
- The Hash Map and Stack courses help for the frequency-counting and stack patterns
Course Contents
2. Pattern 1 · Two pointers
3. Pattern 2 · Frequency counting
4. Pattern 3 · Scan and build
5. Pattern 4 · Stack
6. Pattern 5 · Sliding window
7. Pattern 6 · Expand around the centre
8. Pattern 7 · Backtracking
9. Pattern 8 · String matching
10. Pattern 9 · Dynamic programming on strings
Related courses
- ArraysContiguous, indexable memory — the foundation almost every other data structure builds on.12 lessons · 16 problems
- Hash MapKey → value lookups in O(1) on average — the tool behind counting, “seen it before?” checks, prefix sums and sliding windows.4 lessons · 11 problems
- StackLast-in, first-out — the structure behind call stacks, undo history, and expression parsing.6 lessons · 13 problems
