Skip to content

Commit fde6a4a

Browse files
committed
docs: add complexity comments for maximum-subarray
1 parent 68408c9 commit fde6a4a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

maximum-subarray/reeseo3o.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
/**
1+
/**
2+
* DFS
23
* Time complexity: O(n)
34
* Space complexity: O(h) - h is the height of the tree, worst case O(n)
45
*/
@@ -11,7 +12,11 @@ const maxDepth = (root) => {
1112
return 1 + Math.max(leftDepth, rightDepth);
1213
};
1314

14-
// BFS - TC: O(n) | SC: O(n)
15+
/**
16+
* BFS
17+
* Time complexity: O(n)
18+
* Space complexity: O(n)
19+
*/
1520
const maxDepthBFS = (root) => {
1621
if (root === null) return 0;
1722

0 commit comments

Comments
 (0)