File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change 1
1
// complexity
2
2
// time: O(n^2)
3
+ // - sort: O(n log n)
4
+ // - for loop: O(n)
5
+ // - while loop: O(n)
3
6
// space: O(n)
7
+ // - sortedNums: O(n)
8
+ // - else : O(1)
4
9
5
10
var threeSum = function ( nums ) {
6
11
const sortedNums = nums . sort ( ( a , b ) => a - b )
Original file line number Diff line number Diff line change 1
1
// complexity
2
2
// time: O(n)
3
+ // - for loop: O(n)
3
4
// space: O(1)
5
+ // - nμ κ΄κ³μμ΄ μμκ°μ λ³μλ§ μ¬μ©λλ―λ‘ O(1)
4
6
5
7
var climbStairs = function ( n ) {
6
8
let num1 = 1 ;
Original file line number Diff line number Diff line change 1
1
// complexity
2
2
// time: O(n log n)
3
+ // - sort: O(n log n)
4
+ // - split: O(n)
5
+ // - join: O(n)
3
6
// space: O(n)
7
+ // - sortedS: O(n)
8
+ // - sortedT: O(n)
9
+ // - else : O(1)
4
10
5
11
var isAnagram = function ( s , t ) {
6
12
return s . split ( '' ) . sort ( ) . join ( '' ) === t . split ( '' ) . sort ( ) . join ( '' )
You canβt perform that action at this time.
0 commit comments