mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-28 12:43:12 +08:00
algorithms: fix string split time complexity
This commit is contained in:
@ -53,7 +53,7 @@ Here we assume the other string is of length m.
|
|||||||
| Find substring | O(n.m) | This is the most naive case. There are more efficient algorithms for string searching such as the [KMP algorithm](https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm) |
|
| Find substring | O(n.m) | This is the most naive case. There are more efficient algorithms for string searching such as the [KMP algorithm](https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm) |
|
||||||
| Concatenating strings | O(n + m) | |
|
| Concatenating strings | O(n + m) | |
|
||||||
| Slice | O(m) | |
|
| Slice | O(m) | |
|
||||||
| Split (by token) | O(m) | |
|
| Split (by token) | O(n + m) | |
|
||||||
| Strip (remove leading and trailing whitespaces) | O(n) | |
|
| Strip (remove leading and trailing whitespaces) | O(n) | |
|
||||||
|
|
||||||
## Things to look out for during interviews
|
## Things to look out for during interviews
|
||||||
|
Reference in New Issue
Block a user