โ Back
AlgorithmBeginner
๐งต
String Manipulation
Transform and analyze text
โฑ๏ธ 6โ10 hours๐งฉ 10 LeetCode
๐ Login to unlock solutions and track progress. Login
What is it?
A string is just text โ a sequence of characters. String manipulation is what you do when you want to transform, inspect, or extract parts of that text.
Think of it like editing a word document: lower-case everything, find a word, swap it for another, or read it backwards.
Common Techniques
- Two pointers โ check palindromes or reverse in-place
- Frequency map โ detect anagrams, count characters
- Stack โ validate bracket pairs, decode compressed strings
- Sliding window โ find the longest substring without repeats
- HashMap โ group anagrams together
Real-World Examples
Password strength check
Autocorrect & spellcheck
CSV / JSON text parsing
URL slug generator
Find & Replace in editor
Plagiarism detection
Code Example
What this code shows
On 'Hello, World!': lower-case converts every letter to its small form. includes() checks whether the substring 'World' exists inside. Reversing the characters gives the string read backwards.
const s = "Hello, World!";
// convert every character to lower-case
console.log(s.toLowerCase()); // "hello, world!"
// check if a substring exists anywhere inside
console.log(s.includes("World")); // true
// spread into chars, reverse the array, join back to string
console.log([...s].reverse().join("")); // "!dlroW ,olleH"Expected Output
hello, world! true !dlroW ,olleH