Skip to content

Strings

Course: Intro Class - DSA - chapter 4

Array / List of characters is called a string. It is a collection of alphabets, words or other characters

Example:

"Hello world"
"Hello"
"Hello, I am 2020 graduate"

As it is a list of characters, you can perform similar operations on strings like arrays. Also the language often provides you with more capabilities for string apart from the array operations like splitting a string, searching for a substring within a string etc.

💡 In some languages (ex: Python, Java), strings are immutable even if arrays are not immutable.

💡 Whenever you get a string problem, try determining the possible set of characters. For example, if it is only lowercase or uppercase english alphabets, there are only 26 of them. If all characters (Extended ASCII) are allowed there are 256 of them.