Skip to content

Commit 34a5074

Browse files
authored
[String] Update space complexity to Count and Say
1 parent 7b47149 commit 34a5074

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

String/CountAndSay.swift

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
/**
22
* Question Link: https://leetcode.com/problems/count-and-say/
3-
* Primary idea: Recursive iteration, use outer iteration to count times,
4-
* use inner iteration to get the right string for specific index
3+
* Primary idea: Recursion to get previous string, then iterate and generate current one.
54
*
6-
* Note: Swift does not have a way to access a character in a string with O(1),
7-
* thus we have to first transfer the string to a character array
8-
* Time Complexity: O(n^2), Space Complexity: O(n)
5+
* Time Complexity: O(n^2), Space Complexity: O(1)
96
*
107
*/
118

0 commit comments

Comments
 (0)