<aside>

This section is part of the 5-hour LeetCode DSA Foundations course by Mukul Raina

C11: DSA Foundations for Interviews

Section 4: Strings


SLIDE 31: Section Intro, Strings

Section 4: Strings

String problems are the second most common category in coding interviews, behind arrays. They appear at every level from phone screens to onsite rounds, and companies like Google, Amazon, and Microsoft draw heavily from the string problem pool for fresh graduate hiring.

The good news: if you understood Section 3 (Arrays) well, you already know roughly half of what you need for strings. A Java String is backed by a character array, so techniques like two pointers, frequency counting, and sliding windows apply directly. This section teaches the other half: Java-specific string behavior that creates hidden performance traps, palindrome and anagram patterns that appear repeatedly, and the character frequency toolkit that underpins dozens of problems.

What We’ll Cover:

  1. Java string internals: immutability, StringBuilder, and the .equals() pitfall
  2. Palindrome detection with two pointers and expand-around-center
  3. Anagram detection and grouping with character frequency
  4. Choosing between int[26], int[128], and HashMap for frequency maps
  5. Worked example: Longest Substring Without Repeating Characters
  6. Common string mistakes and how to avoid them

Where Strings Connect to Other Sections:

Connection Section How It Applies
Character frequency maps are hash maps applied to characters Section 5: Hash Maps Same lookup optimization, character-scoped
Two-pointer palindrome check uses the opposite-direction pattern Section 6: Two Pointers Left and right pointers moving inward
“Longest/shortest substring with condition” is a sliding window Section 7: Sliding Window Variable-size window on a character array
Subsequence problems (not substring) require DP C6: Trees, Graphs, DP Different course, different technique

<aside>

Mukul Raina | youtube.com/@mukulraina | linkedin.com/in/mukulraina

</aside>