Skip to content

Resource · Guide or article

String cheatsheet for coding interviews

String notes that build on the array page, which the page asks you to read first. They cover the main buckets string questions fall into: counting characters, anagrams, and palindromes.

Reviewed

Open the original: String cheatsheet for coding interviews (opens the original site in a new tab)

Practice this topicOpens the practice interviewer in Technical / coding mode; choose a question there.

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

A string is a sequence of characters. Many tips that apply to arrays also apply to strings. You're recommended to read the page on Arrays before reading this page.

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Cheatsheet

What it covers

  • Complexity table for operations against a second string: naive substring search O(n times m), concatenation, slice, split, and strip.
  • Argues a counter over lowercase Latin letters is O(1) space, and shows a 26-bit bitmask for strings of unique characters.
  • Three anagram checks, sorting, prime-product mapping, and frequency counting, each with its cost.
  • Palindrome checks with inward pointers, and counting palindromes by expanding outward from each odd and even center.
  • Names Rabin Karp, KMP, tries, and suffix trees as further tools, linking to Wikipedia.

How to use it

PrepKit study advice, not a claim made by the source.

Solve a palindromic substring problem by expanding around centers and explain why each center is checked twice. Then write the bitmask trick and use it to test whether two words share a letter.

Scope and limitations

The O(1) space argument assumes lowercase Latin input; other character sets are not discussed. KMP and Rabin Karp are only linked. One problem is marked LeetCode Premium. Ends with an imported Recommended courses block whose links are not in the recorded file, so PrepKit has not reviewed them.

Access and format

Web page on techinterviewhandbook.org, free to read online in English; the text comes from the MIT-licensed yangshun/tech-interview-handbook repository.

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: e1d28e8886c0

Evidence behind this overview
  • apps/website/contents/algorithms/string.md

Related preparation

These are PrepKit study suggestions, not employer endorsements or predictions of interview questions.

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email