DSA Factory
All free lessons
Level 1 · Foundations

Free Strings lessons

24 lessons, about 218 minutes in all. Each teaches one idea with a visual, then gives you one problem built for it. Read the lessons here, then create a free account to solve the problems and keep your progress.

Stage 0Walking a string

  1. A string is a row of charactersVisit each character of a string and count the vowels.6 min
  2. Building a new stringBuild a reversed copy of a string, one character at a time.7 min
  3. Compare from both endsCheck whether a string reads the same both ways.7 min
  4. Letters are numbersUse character codes to shift every letter along the alphabet.9 min

Stage 1Counting characters

  1. Twenty-six boxesCount every letter with a list of 26 counters, one per letter.7 min
  2. Same letters, any orderTwo words are anagrams when their letter counts match.7 min
  3. Count first, then lookFind the first character that appears only once, in two passes.7 min
  4. Enough letters?Check whether one word can be spelled from another's letters.7 min

Stage 2Two pointers on text

  1. Find a word's two endsWalk from the end, marking where each word starts and stops.9 min
  2. One mismatch allowedCheck whether deleting at most one character makes a palindrome.10 min
  3. Measure each runShorten a string by writing each run of a letter once, with its length.8 min
  4. Two strings, two pointersWeave two strings together, one character from each in turn.6 min

Stage 3Windows on text

  1. Jump past the repeatThe longest stretch of text with no repeated character.10 min
  2. Slide the letter countsFind every place where a rearrangement of a word appears.10 min
  3. At most k kindsThe longest stretch of text using at most k different characters.10 min
  4. Cover everything, then tightenThe shortest stretch of text that contains every character of a pattern.14 min

Stage 4Parsing

  1. Reading a number from textTurn the digits at the start of a string into a whole number, carefully.10 min
  2. Cut at every separatorSplit a line into pieces wherever a separator character appears.8 min
  3. Column by columnFind the longest start that every word shares.8 min
  4. Compare piece by pieceDecide which of two version numbers like 1.10 and 1.9 is newer.10 min

Stage 5Mastery

  1. Build a palindromeThe longest palindrome you can make from a pile of letters.10 min
  2. Made of copies?Decide whether a string is one piece repeated several times.10 min
  3. Longest mirror insideThe longest stretch of a string that reads the same both ways.14 min
  4. Exactly k kindsCount the stretches that use exactly k different characters.14 min

There’s more after this

These are the opening stages of Strings. The full path climbs on to harder problems and a mastery test. Create a free account and we’ll keep your place.

Start the full path free