728x90
[Javascript] LeetCode 344. Reverse String
💡 구글에 Javascript 풀이가 많이 없거나, 배운 점이 있으면 포스팅합니다.
내 풀이
/**
* @param {character[]} s
* @return {void} Do not return anything, modify s in-place instead.
*/
var reverseString = function(s) {
for (let i = 0; i < Math.floor(s.length / 2); i++) {
[s[i], s[(s.length - 1) - i]] = [s[(s.length - 1) - i], s[i]];
}
};
내 풀이 2
/**
* @param {character[]} s
* @return {void} Do not return anything, modify s in-place instead.
*/
var reverseString = (s) => s.reverse();
- 이걸 올려야 되나 말아야 되나 🤣
'Coding Test > LeetCode' 카테고리의 다른 글
[Javascript] (LeetCode) 26. Remove Duplicates from Sorted Array (Easy) (0) | 2022.07.20 |
---|---|
[Javascript] (LeetCode) 19. Remove Nth Node From End of List (Medium) (0) | 2022.07.14 |
[Javascript] LeetCode 876. Middle of the Linked List (0) | 2022.07.14 |
[Javascript] LeetCode 557. Reverse Words in a String III (0) | 2022.07.13 |
[Javascript] LeetCode 167. Two Sum II - Input Array Is Sorted (0) | 2022.07.13 |
오름차순 (Ascending order) vs 비 내림차순(non-decreasing order) (0) | 2022.07.13 |
[Javascript] LeetCode 283. Move Zeroes (0) | 2022.07.13 |
[Javascript] LeetCode 189. Rotate Array (0) | 2022.07.11 |
댓글