File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 101
101
283|[ Move Zeroes] ( ./0283-move-zeroes.js ) |Easy|
102
102
326|[ Power of Three] ( ./0326-power-of-three.js ) |Easy|
103
103
342|[ Power of Four] ( ./0342-power-of-four.js ) |Easy|
104
+ 344|[ Reverse String] ( ./0344-reverse-string.js ) |Easy|
104
105
345|[ Reverse Vowels of a String] ( ./0345-reverse-vowels-of-a-string.js ) |Easy|
105
106
347|[ Top K Frequent Elements] ( ./0347-top-k-frequent-elements.js ) |Medium|
106
107
349|[ Intersection of Two Arrays] ( ./0349-intersection-of-two-arrays.js ) |Easy|
Original file line number Diff line number Diff line change
1
+ /**
2
+ * 344. Reverse String
3
+ * https://leetcode.com/problems/reverse-string/
4
+ * Difficulty: Easy
5
+ *
6
+ * Write a function that reverses a string. The input string is given as an array
7
+ * of characters s.
8
+ *
9
+ * You must do this by modifying the input array in-place with O(1) extra memory.
10
+ */
11
+
12
+ /**
13
+ * @param {character[] } s
14
+ * @return {void } Do not return anything, modify s in-place instead.
15
+ */
16
+ var reverseString = function ( s ) {
17
+ for ( let i = 0 ; i < Math . floor ( s . length / 2 ) ; i ++ ) {
18
+ [ s [ s . length - 1 - i ] , s [ i ] ] = [ s [ i ] , s [ s . length - 1 - i ] ] ;
19
+ }
20
+ } ;
You can’t perform that action at this time.
0 commit comments