Conversation
doitchuu
approved these changes
Apr 3, 2026
| var moveZeroes = function (nums) { | ||
| if (nums.length === 1) return nums; | ||
|
|
||
| if (nums.every((num) => num === 0)) return nums; |
sik9252
approved these changes
Apr 4, 2026
Collaborator
There was a problem hiding this comment.
splice는 매번 배열을 당겨와야하기 때문에 비용이 커진다고 하네요!
저도 문제 딱 보고 투포인터를 먼저 떠올리기는 어렵더라고요ㅠ 그리고 암기식으로 하다보니 투포인터는 left, right 선언하고 둘 다 움직이며 swap 하는 형태 라고 외웠는데 또 이렇게 유형 바뀌니까 뭐지 싶고ㅠ
Collaborator
There was a problem hiding this comment.
이해하기도 쉽고, 코드도 깔끔하게 잘 작성하신 것 같아요!
효율적인 풀이는 slow/fast 포인터와 reverse를 이용해서 O(1) 추가 공간으로 푸는 것 이라고 하네요ㅠ 하지만 저도 실패
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
이렇게 풀었어요
1. Move Zeroes
1) 복잡도 계산
2) 접근 아이디어
3) 회고
해당 문제 풀이는 시간 초과가 발생했다. 풀이를 찾아보니 투 포인터 방식을 사용해서 풀이하는 방식이 있었다. 0이 아닌 값을 앞에서부터 채우고, 나머지를 0으로 채워주면 되는 방식이었다. 너무 어렵게 생각했던 것 같다.
2. Palindrome Linked List
1) 복잡도 계산
2) 접근 아이디어
3) 회고
처음에 set을 통해 구하려고 했다. 처음 나오는 건 set에 추가하고, 다음에 나오는 건 set에서 제거하는 방식으로 풀이하려고 했는데, 순서를 고려하지 않아서 실패했다. 시간 복잡도가 O(1)인 풀이는 떠오르지 않아서, 풀이하지 못했다.