File tree Expand file tree Collapse file tree 4 files changed +72
-0
lines changed Expand file tree Collapse file tree 4 files changed +72
-0
lines changed Original file line number Diff line number Diff line change 10
10
| 5| [ Longest Palindromic] ( https://leetcode.com/problems/longest-palindromic-substring/ ) | [ JavaScript] (./algorithms/Longest Palindromic.js)| Medium|
11
11
| 6| [ ZigZag Conversion] ( https://leetcode.com/problems/zigzag-conversion/ ) | [ JavaScript] (./algorithms/ZigZag Conversion.js)| Easy|
12
12
| 7| [ Reverse Integer] ( https://leetcode.com/problems/reverse-integer/ ) | [ JavaScript] (./algorithms/Reverse Integer.js)| Easy|
13
+ | 8| [ String to Integer (atoi)] ( https://leetcode.com/problems/string-to-integer-atoi/ ) | [ JavaScript] (./algorithms/String to Integer (atoi).js)| Easy|
14
+ | 9| [ Palindrome Number] ( https://leetcode.com/problems/palindrome-number/ ) | [ JavaScript] (./algorithms/Palindrome Number.js)| Easy|
15
+ | 10| [ Container With Most Water] ( https://leetcode.com/problems/container-with-most-water/ ) | [ JavaScript] (./algorithms/Container With Most Water.js)| Medium|
13
16
| 371| [ Sum of Two Integers] ( https://leetcode.com/problems/sum-of-two-integers/ ) | [ JavaScript] (./algorithms/Sum of Two Integers.js)| Easy|
14
17
| 372| [ Super Pow] ( https://leetcode.com/problems/super-pow/ ) | [ JavaScript] ( ./algorithms/SuperPow.js ) | Medium|
15
18
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number[] } height
3
+ * @return {number }
4
+ */
5
+ var maxArea = function ( height ) {
6
+ var max = 0 ,
7
+ temp = 0 ,
8
+ h = 0 ,
9
+ l = 0 ,
10
+ start = 0 ,
11
+ end = height . length - 1 ;
12
+ for ( var i = 0 ; i < height . length - 1 ; i ++ ) {
13
+ l = end - start ;
14
+ if ( height [ start ] > height [ end ] ) {
15
+ h = height [ end ] ;
16
+ end -- ;
17
+ }
18
+ else {
19
+ h = height [ start ] ;
20
+ start ++ ;
21
+ }
22
+ if ( max < h * l ) {
23
+ max = h * l ;
24
+ }
25
+ }
26
+ return max ;
27
+ } ;
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {number } x
3
+ * @return {boolean }
4
+ */
5
+ var isPalindrome = function ( x ) {
6
+ var xString = "" + x ;
7
+ if ( StringReverse ( xString ) === xString ) {
8
+ return true ;
9
+ }
10
+ else {
11
+ return false ;
12
+ }
13
+ } ;
14
+
15
+ function StringReverse ( s ) {
16
+ var result = "" ;
17
+ for ( var i = s . length - 1 ; i >= 0 ; i -- ) {
18
+ result += s [ i ] ;
19
+ }
20
+ return result ;
21
+ }
Original file line number Diff line number Diff line change
1
+ /**
2
+ * @param {string } str
3
+ * @return {number }
4
+ */
5
+ var myAtoi = function ( str ) {
6
+ var result = parseInt ( str ) ;
7
+ if ( str === "" || isNaN ( result ) ) {
8
+ return 0 ;
9
+ }
10
+ else if ( result > Math . pow ( 2 , 31 ) - 1 )
11
+ {
12
+ return Math . pow ( 2 , 31 ) - 1 ;
13
+ }
14
+ else if ( result < - Math . pow ( 2 , 31 ) )
15
+ {
16
+ return - Math . pow ( 2 , 31 ) ;
17
+ }
18
+ else {
19
+ return result ;
20
+ }
21
+ } ;
You can’t perform that action at this time.
0 commit comments