Home / DSA / Lesson 2

Strings — arrays of characters

Beginner 8 min read Lesson 2 of 9

A string is a sequence of characters. In JavaScript, strings are immutable: s[0] = 'A' does not change s. Building a string with repeated + in a loop can be slow; prefer an array of pieces and join('') when you construct large output.

Frequency counting

Anagram check: count letters of A, subtract letters of B, all counts zero. Palindrome: two pointers from both ends, skip non-alphanumerics if the problem says so.

Judge: Valid palindrome, Anagram, Reverse string.

Pattern: Sliding window for longest substring without repeats.