- Tutorials
- DSA Tutorial
- Strings
Strings
3 lessonsAbout 18 minutesBeginner
This part of the DSA Tutorial runs from Strings in JavaScript for DSA through to String Matching: KMP and Rabin-Karp. There are 3 lessons here, and working through them takes about 18 minutes at a steady pace.
It follows on from Arrays, so finish that first if you have not already — the examples below assume you are comfortable with it.
Each lesson below says what it covers before you open it. Read them in order the first time; afterwards this page works as a index you can jump back into when you need to check one thing.
- 1Strings in JavaScript for DSAJavaScript strings are immutable, which makes building them in a loop quadratic. Learn the real cost of string operations and how to build and compare them efficiently.
- 2Common String ProblemsPalindromes, anagrams, reversal and first unique character — the string problems asked most often, each solved in JavaScript with its time and space cost.
- 3String Matching: KMP and Rabin-KarpFinding a pattern inside a string faster than the naive nested loop. KMP and Rabin-Karp explained in JavaScript, with the cases where indexOf is the right answer instead.
