Skip to content

Commit

Permalink
docs: add complexity analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
HiGeuni committed Dec 21, 2024
1 parent 7d63266 commit 736ee84
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions 3sum/higeuni.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 2 additions & 0 deletions climbing-stairs/higeuni.js
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 6 additions & 0 deletions valid-anagram/higeuni.js
Original file line number Diff line number Diff line change
@@ -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('')
Expand Down

0 comments on commit 736ee84

Please sign in to comment.