diff --git a/3sum/higeuni.js b/3sum/higeuni.js index 07a265f3d..d08950171 100644 --- a/3sum/higeuni.js +++ b/3sum/higeuni.js @@ -1,6 +1,11 @@ // complexity // time: O(n^2) +// - sort: O(n log n) +// - for loop: O(n) +// - while loop: O(n) // space: O(n) +// - sortedNums: O(n) +// - else : O(1) var threeSum = function(nums) { const sortedNums = nums.sort((a, b) => a - b) diff --git a/climbing-stairs/higeuni.js b/climbing-stairs/higeuni.js index 9bce31079..ea9b321e0 100644 --- a/climbing-stairs/higeuni.js +++ b/climbing-stairs/higeuni.js @@ -1,6 +1,8 @@ // complexity // time: O(n) +// - for loop: O(n) // space: O(1) +// - n에 관계없이 상수개의 변수만 사용되므로 O(1) var climbStairs = function(n) { let num1 = 1; diff --git a/valid-anagram/higeuni.js b/valid-anagram/higeuni.js index a1aef97f5..72e662abc 100644 --- a/valid-anagram/higeuni.js +++ b/valid-anagram/higeuni.js @@ -1,6 +1,12 @@ // complexity // time: O(n log n) +// - sort: O(n log n) +// - split: O(n) +// - join: O(n) // space: O(n) +// - sortedS: O(n) +// - sortedT: O(n) +// - else : O(1) var isAnagram = function(s, t) { return s.split('').sort().join('') === t.split('').sort().join('')