Conversation
sik9252
approved these changes
Feb 13, 2026
| // MEMO: 시간 초과! | ||
| let maxPrice = 0; | ||
|
|
||
| for (let i = 0; i < prices.length - 1; i++) { |
Collaborator
There was a problem hiding this comment.
시간 초과는 과거 최소값을 유지/갱신 하는 방향으로 코드를 수정하면 O(n)으로 줄일 수 있을 것 같아요!
Collaborator
There was a problem hiding this comment.
저도 못 풀었는데ㅠ 팁을 알려주셔서 감사합니다.
Collaborator
There was a problem hiding this comment.
코드가 직관적이고 이해하기 쉽게 작성된 것 같아요 최고 👍
Collaborator
There was a problem hiding this comment.
if만 사용하면 각 조건을 모두 독립적으로 검사하게 되는 것으로 알고 있는데, 그렇기 때문에 아래와 같은 의도치 않은 비교가 발생할 수도 있을 것 같아요.
- 첫 번째 if에서 pop()이 실행
- 두 번째 조건도 if기 때문에 또 검사함
- 이때 이미 이전 조건에서 pop()이 일어나 stack[stack.length - 1] 값이 바뀐 상태임
그래서 이런식으로 if-elseif를 사용해서 작성하는게 조금 더 안전하지 않을까? 하는 생각을 해보았습니다!
if (ch === ")" && top === "(") stack.pop();
else if (ch === "}" && top === "{") stack.pop();
else if (ch === "]" && top === "[") stack.pop();
raejun92
approved these changes
Feb 13, 2026
Comment on lines
+7
to
+9
| if (s.length % 2 !== 0) { | ||
| return false; | ||
| } |
Collaborator
There was a problem hiding this comment.
count는 어떤 용도로 사용하고 있는 걸까요?
| // MEMO: 시간 초과! | ||
| let maxPrice = 0; | ||
|
|
||
| for (let i = 0; i < prices.length - 1; i++) { |
Collaborator
There was a problem hiding this comment.
저도 못 풀었는데ㅠ 팁을 알려주셔서 감사합니다.
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. Two Sort
1) 복잡도 계산
2) 접근 아이디어
3) 회고
N제곱에서 N으로 줄이려면 Map을 사용하는 풀이도 있다. 해당 풀이로 디벨롭해도 좋을 듯합니다.
2. Valid Parentheses
1) 복잡도 계산
2) 접근 아이디어
3) 회고
객체로 만들어 확인하는 방법도 직관적인 것 같습니다. 풀이방식을 항상 여러갈래로 고민해봐야 발전할 것 같아요.
아래 방식으로 푼 풀이도 좋은 것 같습니다!
3. Merge Two Sorted List
1) 회고
링크드리스트 자료구조에 대한 이해와, 코드로 구현하는 능력이 부족했던 것 같습니다.
아래 풀이 방식보고, 정답이 잊혀지면 다시 풀어봐야할 것 같아요
4. Best Time To Buy And Sell Stock
1) 회고
해당 문제는 풀지 못해서, AI의 도움으로 접근법을 확인했습니다.
다른 분들 풀이 보면서 참고해서 다시 풀어보면 좋을 것 같습니다.