From 0209ea7ce10c1fd3b5840f51f0093245c3a6eb17 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Mon, 18 Jul 2022 07:13:28 +0800 Subject: [PATCH] algorithms: fix string split time complexity --- contents/algorithms/string.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/algorithms/string.md b/contents/algorithms/string.md index 80e15b95..74472413 100644 --- a/contents/algorithms/string.md +++ b/contents/algorithms/string.md @@ -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) | | Concatenating strings | O(n + m) | | | Slice | O(m) | | -| Split (by token) | O(m) | | +| Split (by token) | O(n + m) | | | Strip (remove leading and trailing whitespaces) | O(n) | | ## Things to look out for during interviews