File tree Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Expand file tree Collapse file tree 3 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 39
39
| 43| [ Multiply Strings] ( https://leetcode.com/problems/multiply-strings/ ) | [ JavaScript] ( ./algorithms/Multiply_Strings.js ) | Medium|
40
40
| 46| [ Permutations] ( https://leetcode.com/problems/permutations/ ) | [ JavaScript] ( ./algorithms/Permutations.js ) | Medium|
41
41
| 47| [ Permutations II] ( https://leetcode.com/problems/permutations-ii/ ) | [ JavaScript] ( ./algorithms/PermutationsII.js ) | Medium|
42
- | 48| [ Rotate Image] ( https://leetcode.com/problems/permutations-ii/ ) | [ JavaScript] ( ./algorithms/RotateImage.js ) | Medium|
42
+ | 48| [ Rotate Image] ( https://leetcode.com/problems/rotate-image/ ) | [ JavaScript] ( ./algorithms/RotateImage.js ) | Medium|
43
+ | 49| [ Group Anagrams] ( https://leetcode.com/problems/group-anagrams/ ) | [ JavaScript] (./algorithms/group Anagrams.js)| Medium|
44
+ | 50| [ Pow(x, n)] ( https://leetcode.com/problems/powx-n/ ) | [ JavaScript] (./algorithms/Pow(x, n).js)| Medium|
43
45
| 69| [ Sqrt(x)] ( https://leetcode.com/problems/sqrtx/ ) | [ JavaScript] ( ./algorithms/Sqrt(x).js ) | Easy|
44
46
| 371| [ Sum of Two Integers] ( https://leetcode.com/problems/sum-of-two-integers/ ) | [ JavaScript] ( ./algorithms/Sum_of_Two_Integers.js ) | Easy|
45
47
| 372| [ Super Pow] ( https://leetcode.com/problems/super-pow/ ) | [ JavaScript] ( ./algorithms/SuperPow.js ) | Medium|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number } x
3
+ * @param {number } n
4
+ * @return {number }
5
+ */
6
+ var myPow = function ( x , n ) {
7
+ var flag = false ,
8
+ p = x ,
9
+ res = 1
10
+ if ( n < 0 ) {
11
+ flag = true ;
12
+ }
13
+ for ( var i = Math . abs ( n ) ; i > 0 ; i = Math . floor ( i / 2 ) ) {
14
+ if ( i % 2 !== 0 ) {
15
+ res = res * p ;
16
+ }
17
+ p = p * p ;
18
+ }
19
+ result = flag ? 1 / res : res ;
20
+ return result
21
+ } ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {string[] } strs
3
+ * @return {string[][] }
4
+ */
5
+ var groupAnagrams = function ( strs ) {
6
+ var result = [ ] ,
7
+ obj = { } ,
8
+ pipe = function ( str ) {
9
+ return str . split ( '' ) . sort ( ) . join ( '' ) ;
10
+ }
11
+ for ( var i = 0 ; i < strs . length ; i ++ ) {
12
+ if ( obj [ pipe ( strs [ i ] ) ] === undefined ) {
13
+ obj [ pipe ( strs [ i ] ) ] = result . length ;
14
+ result . push ( [ ] . concat ( strs [ i ] ) ) ;
15
+ } else {
16
+ result [ obj [ pipe ( strs [ i ] ) ] ] . push ( strs [ i ] ) ;
17
+ }
18
+ }
19
+ return result ;
20
+ } ;
You can’t perform that action at this time.
0 commit comments