A lesson from the data structures and algorithms bootcamp. About a 10 minute read.
A string is an array of characters with one extra rule: in most languages you cannot change it. That single rule is behind most string performance bugs, and the rest of the topic is a small set of habits.
An ordered sequence of characters, indexable like an array with s[0] and walkable one character at a time. Everything from the arrays lesson carries over, including the cache behaviour, which is why scanning a string is about as fast as scanning anything gets.
The rest of this lesson continues with 4 further sections. See the full curriculum.
Browse all 536 practice puzzles