Conversation
…alid Palindrome solutions
sik9252
approved these changes
Feb 20, 2026
Comment on lines
+33
to
+34
| if (nums[start] === target) return start; | ||
| if (nums[end] === target) return end; |
Collaborator
There was a problem hiding this comment.
시간 복잡에는 문제가 없는거 같지만, 왜 이 비교(매 루프마다 양 끝 비교하는 부분)가 필요한지의 관점에서 보면 mid 비교만 남긴다면 더 단순해질 것 같아요!
Collaborator
Author
There was a problem hiding this comment.
그렇네요 반복문 전에 한 번 확인하고 반복문에서는 mid만 확인하면 될 것 같아요!
| */ | ||
| var floodFill = function (image, sr, sc, color) { | ||
| const queue = [[sr, sc]]; | ||
| let cur = 0; |
Collaborator
There was a problem hiding this comment.
오 shift() 말고 바로 포인터 방식 떠올리셨나요? 대박
| * @return {TreeNode} | ||
| */ | ||
| var invertTree = function (root) { | ||
| function change(root) { |
Collaborator
There was a problem hiding this comment.
change 재정의 안하고 invertTree 자체를 재귀로 돌려도 좋을 것 같슴다! 저도 재귀 넘 어려워요ㅠ
doitchuu
approved these changes
Feb 21, 2026
| var isAnagram = function (s, t) { | ||
| s = s | ||
| .split("") | ||
| .sort((a, b) => a.charCodeAt() - b.charCodeAt()) |
Member
There was a problem hiding this comment.
charCodeAt 메서드로도 풀 수 있군요..!
메서드체이닝으로 코드가 간단해져서 풀이가 잘 보이네요 👍
| (s) => | ||
| (48 <= s.charCodeAt() && s.charCodeAt() <= 57) || | ||
| (97 <= s.charCodeAt() && s.charCodeAt() <= 122), | ||
| ); |
| if문의 예외 처리를 생각하지 못하여 풀이를 하지 못하였다. | ||
| 다른 사람들의 풀이를 보니 DFS로 푼 것이 공간 및 시간 복잡도 측면에서 더 효율적으로 나왔다. | ||
| 왜 그런 걸까? | ||
| */ |
Member
There was a problem hiding this comment.
저도 다른 사람 풀이를 보긴 했는데,
BFS로 푼 방식도 좋은 풀이인 것 같습니다 👍
shift 메서드를 쓰시지 않아서 더 좋은 것 같아욥
Collaborator
Author
There was a problem hiding this comment.
shift를 쓰지않고 BFS로 풀어도 DFS가 더 좋게 나오더라구요!
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. Valid Palindrome
1) 복잡도 계산
시간 복잡도: O(n)
2) 접근 아이디어
3) 회고
평소 정규표현식에 대한 지식이 있다면 더 간단하게 풀이할 수 있었을 것 같다.
메서드가 익숙지 않아 시간이 다소 걸렸지만, 풀이 자체는 어렵지 않았다.
2. Valid Anagram
1) 복잡도 계산
시간 복잡도: O(nlogn) — 정렬 사용
2) 접근 아이디어
3) 회고
정렬을 이용한 간단한 풀이로 빠르게 해결했다.
3. Binary Search
1) 복잡도 계산
시간 복잡도: O(logn)
2) 접근 아이디어
3) 회고
처음에 양 끝에서부터 하나씩 비교해가며 target과 같은 값이 있는지 확인하는 방식으로 풀이했는데, 시간 복잡도가 O(n)이어서 이진 탐색 알고리즘을 이용하여 다시 풀이했다.
4. Invert Binary Tree
1) 복잡도 계산
시간 복잡도: O(n)
2) 접근 아이디어
3) 회고
재귀가 익숙하지 않아 풀이하는 데 시간이 다소 걸렸다.
완전 이진트리와 이진트리 개념이 헷갈려서 풀이하는 데 시간이 더 걸렸던 것 같다.
5. Flood Fill
1) 복잡도 계산
시간 복잡도: O(n) — 모든 픽셀을 최대 한 번 방문
2) 접근 아이디어
3) 회고
BFS를 이용해서 문제를 풀려고 했다.
2차원 배열의 row와 col이 다소 헷갈렸고 반복문의 조건 설정이 어려웠다.
if문의 예외 처리를 생각하지 못하여 풀이를 완료하지 못하였다.
다른 사람들의 풀이를 보니 DFS로 푼 것이 공간 및 시간 복잡도 측면에서 더 효율적으로 나왔다. 왜 그런 걸까?