11. Strings
StringBuilder, palindromes, anagrams, frequency counting and top string questions.
🎬 Episodes 16–20: video coming soon
Your progress0 of 15
7easy
8medium
0hard
Understand the topic
In Java a String can't be changed; every "change" makes a new String. Use StringBuilder to build text, and toCharArray() when you need to edit characters.
Most string questions use one of these ideas: a frequency array of 26 or 128 counts (anagrams, unique letters), two pointers from the ends (palindromes), expanding around a centre (palindromic substrings), or a HashMap with a canonical key (grouping).
| # | Problem | Pattern | Level | ||
|---|---|---|---|---|---|
| 1 | Longest Common Prefix #14 | Vertical scan | Easy | LeetCode ↗ | |
| 2 | Valid Anagram #242 | Frequency count | Easy | LeetCode ↗ | |
| 3 | First Unique Character in a String #387 | Frequency count | Easy | LeetCode ↗ | |
| 4 | Roman to Integer #13 | Look-ahead | Easy | LeetCode ↗ | |
| 5 | Isomorphic Strings #205 | Two-way mapping | Easy | LeetCode ↗ | |
| 6 | Longest Palindrome #409 | Frequency count | Easy | LeetCode ↗ | |
| 7 | Ransom Note #383 | Frequency count | Easy | LeetCode ↗ | |
| 8 | Group Anagrams #49 | Canonical key + HashMap | Medium | LeetCode ↗ | |
| 9 | Reverse Words in a String #151 | Split & rebuild | Medium | LeetCode ↗ | |
| 10 | Longest Palindromic Substring #5 | Expand around centre | Medium | LeetCode ↗ | |
| 11 | String to Integer (atoi) #8 | Parsing with overflow clamp | Medium | LeetCode ↗ | |
| 12 | Palindromic Substrings #647 | Expand around centre | Medium | LeetCode ↗ | |
| 13 | Sort Characters By Frequency #451 | Count + bucket | Medium | LeetCode ↗ | |
| 14 | Integer to Roman #12 | Greedy table | Medium | LeetCode ↗ | |
| 15 | String Compression #443 | Read/write pointers | Medium | LeetCode ↗ |
Nothing matches that filter.
Work top to bottom — each list goes from easy to hard. Try a problem for at least 15 minutes before opening a hint. Ticks are saved in your browser.