File tree Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Expand file tree Collapse file tree 3 files changed +24
-0
lines changed Original file line number Diff line number Diff line change 1+ // week2 goal
2+ // not knowing how to express, I googled and referenced a bit
3+ function climbStairs ( n : number ) : number {
4+ let stairArray : number [ ] = [ 1 , 2 ]
5+ for ( let i = 2 ; i < n ; i ++ ) {
6+ stairArray . push ( stairArray [ i - 1 ] + stairArray [ i - 2 ] )
7+ }
8+ return stairArray [ n - 1 ]
9+ } ;
Original file line number Diff line number Diff line change 1+ // frequency is k times
Original file line number Diff line number Diff line change 1+ // week 2's goal
2+ // only focusing on not using for... not a good approach :(
3+
4+ function isAnagram ( s : string , t : string ) : boolean {
5+ if ( s . length !== t . length ) return false
6+ let sArray : string [ ] = s . split ( '' ) . sort ( )
7+ s = sArray . join ( '' )
8+ let tArray : string [ ] = t . split ( '' ) . sort ( )
9+ t = tArray . join ( '' )
10+ if ( s === t ) return true
11+ else return false
12+ } ;
13+
14+ // reflection: not to be hurry & have more time for pondering
You can’t perform that action at this time.
0 commit comments