# String Cheatsheet A string is a sequence of characters. Many tips that apply to Arrays also apply to Strings. #### Time complexity[​](https://www.techinterviewhandbook.org/algorithms/string/#time-complexity "Direct link to Time complexity") A Strings is an array of characters, so the time complexities of basic string operations will closely resemble that of array operations.
OperationBig-O
AccessO(1)
SearchO(n)
InsertO(n)
RemoveO(n)
#### Operations involving another String[​](https://www.techinterviewhandbook.org/algorithms/string/#operations-involving-another-string "Direct link to Operations involving another string") Here we assume the other string is of length m.
OperationBig-O
Find substringO(n.m)
Concatenating stringsO(n + m)
SliceO(m)
Split (by token)O(n + m)
Strip (remove leading and trailing whitespaces)O(n)
#### Things to look out for during interviews[​](https://www.techinterviewhandbook.org/algorithms/string/#things-to-look-out-for-during-interviews "Direct link to Things to look out for during interviews") - Ask about input character set and case sensitivity. #### Corner cases[​](https://www.techinterviewhandbook.org/algorithms/string/#corner-cases "Direct link to Corner cases") - Empty string - String with 1 or 2 characters - String with repeated characters - Strings with only distinct character