File tree 3 files changed +66
-1
lines changed
3 files changed +66
-1
lines changed Original file line number Diff line number Diff line change @@ -22,9 +22,12 @@ Progress: 20/
22
22
| 182| [ Duplicate Emails] ( https://leetcode.com/problems/duplicate-emails/ ) | [ SQL] ( ./src/duplicate-emails/res.txt ) | Easy|
23
23
| 183| [ Customers Who Never Order] ( https://leetcode.com/problems/customers-who-never-order/ ) | [ SQL] ( ./src/customers-who-never-order/res.txt ) | Easy|
24
24
| 184| [ Department Highest Salary] ( https://leetcode.com/problems/department-highest-salary/ ) | [ SQL] ( ./src/department-highest-salary/res.txt ) | Medium|
25
- | 190| [ Reverse Bits] ( https://leetcode.com/problems/reverse-bits/ ) | [ JavaScript] ( ./src/reverse-bits/res.txt ) | Easy|
25
+ | 190| [ Reverse Bits] ( https://leetcode.com/problems/reverse-bits/ ) | [ JavaScript] ( ./src/reverse-bits/res.js ) | Easy|
26
26
| 196| [ Delete Duplicate Emails] ( https://leetcode.com/problems/delete-duplicate-emails/ ) | [ SQL] ( ./src/delete-duplicate-emails/res.txt ) | Easy|
27
27
| 197| [ Rising Temperature] ( https://leetcode.com/problems/rising-temperature/ ) | [ SQL] ( ./src/rising-temperature/res.txt ) | Easy|
28
+ | 206| [ Reverse Linked List] ( https://leetcode.com/problems/reverse-linked-list/ ) | [ JavaScript] ( ./src/reverse-linked-list/res.js ) | Easy|
28
29
| 342| [ Power of Four] ( https://leetcode.com/problems/power-of-four/ ) | [ JavaScript] ( ./src/power-of-four/res.js ) | Easy|
30
+ | 344| [ Reverse String] ( https://leetcode.com/problems/reverse-string/ ) | [ JavaScript] ( ./src/reverse-string/res.js ) | Easy|
29
31
| 404| [ Sum of Left Leaves] ( https://leetcode.com/problems/sum-of-left-leaves/ ) | [ JavaScript] ( ./src/sum-of-left-leaves/res.js ) | Easy|
30
32
| 434| [ Number of Segments in a String] ( https://leetcode.com/problems/number-of-segments-in-a-string/ ) | [ JavaScript] ( ./src/number-of-segments-in-a-string/res.js ) | Easy|
33
+ || [ ] ( ) | [ ] ( ./src//res.js ) | Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * Reverse a singly linked list.
3
+ *
4
+ * res.js
5
+ * @authors Joe Jiang ([email protected] )
6
+ * @date 2017-02-25 21:12:51
7
+ * @version $Id$
8
+ */
9
+
10
+ /**
11
+ * Definition for singly-linked list.
12
+ * function ListNode(val) {
13
+ * this.val = val;
14
+ * this.next = null;
15
+ * }
16
+ */
17
+ /**
18
+ * @param {ListNode } head
19
+ * @return {ListNode }
20
+ */
21
+ let reverseList = function ( head ) {
22
+ if ( ! head ) {
23
+ return head ;
24
+ }
25
+
26
+ let res = new ListNode ( head . val ) ;
27
+
28
+ while ( head . next ) {
29
+ let temp = res ;
30
+ res = new ListNode ( head . next . val ) ;
31
+ res . next = temp ;
32
+ head = head . next ;
33
+ }
34
+
35
+ return res ;
36
+ } ;
Original file line number Diff line number Diff line change
1
+ // Write a function that takes a string as input and returns the string reversed.
2
+
3
+ // Example:
4
+ // Given s = "hello", return "olleh".
5
+
6
+ /**
7
+ * res.js
8
+ * @authors Joe Jiang ([email protected] )
9
+ * @date 2017-02-25 21:23:03
10
+ * @version $Id$
11
+ */
12
+
13
+ /**
14
+ * @param {string } s
15
+ * @return {string }
16
+ */
17
+ let reverseString = function ( s ) {
18
+ let res = '' ;
19
+
20
+ while ( s ) {
21
+ res = s . charAt ( 0 ) + res ;
22
+ s = s . substring ( 1 ) ;
23
+ }
24
+
25
+ return res ;
26
+ } ;
You can’t perform that action at this time.
0 commit comments