String Problems for Coding Interviews

String problems test careful indexing and the right data structure: a hash map of counts, two pointers for palindromes, a sliding window for substrings and a stack for brackets. Know how your language stores strings, because immutability changes the cost of building them.

Common themes are anagrams, palindromes, longest substring conditions, parsing and matching. Practise stating the complexity of your solution and the edge cases (empty string, one character, repeated characters). Open any problem to run your code against test cases.

Coding problems

Related

Frequently asked questions

How do I get good at string problems?

Solve a few problems of each difficulty, name the pattern after you solve each one, and revisit the ones you needed hints for a week later. The list on this page is ordered so you can start with the basic ones.

Can I run string problems online here?

Yes. Every problem opens in an editor that runs your code against test cases in Java, Python, C++, Go, JavaScript and six more languages, with no setup.