-
-
Notifications
You must be signed in to change notification settings - Fork 245
[grapefruitgreentealoe] WEEK 01 solutions #1130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
grapefruitgreentealoe
merged 10 commits into
DaleStudy:main
from
grapefruitgreentealoe:main
Apr 6, 2025
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
209e13c
feat: contains-duplicate solution
grapefruitgreentealoe 7f4c264
refactor: for문 변수 선언 시 let 키워드 추가
grapefruitgreentealoe 3856037
feat: two-sum solution
grapefruitgreentealoe 9e20a2f
refactor: two-sum
grapefruitgreentealoe 9bbc17b
chore: two-sum 시간, 공간복잡도 주석 추가
grapefruitgreentealoe 9905453
feat: top-k-frequent-elements solution
grapefruitgreentealoe d8a48f5
refactor: for of 연산으로 수정
grapefruitgreentealoe 41af5db
feat: longest-consectuive-sequence solution
grapefruitgreentealoe db96ca4
chore: 주석
grapefruitgreentealoe 49f3bce
feat: house-robber solution
grapefruitgreentealoe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/** | ||
* @param {number[]} nums | ||
* @return {boolean} | ||
*/ | ||
|
||
/** | ||
* 문제설명: 2개 이상 반복되는 값이 있으면 true, 모두 반복되지 않으면 false. | ||
|
||
제한사항 | ||
1 <= nums.length <= 10^5 | ||
-109 <= nums[i] <= 109 | ||
*/ | ||
|
||
var containsDuplicate = function (nums) { | ||
const numberSet = new Set(); | ||
//시간 복잡도 O(n) | ||
for (i of nums) { | ||
if (!numberSet.has(i)) { | ||
//공간복잡도 O(n) | ||
numberSet.add(i); | ||
} else { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요! 첫 리뷰 남겨봅니다!
i 변수가 let, const로 선언되어 있지 않아 JS에서 자동으로 전역 변수로 취급되어 글로벌 스코프 오염 문제가 발생할 수 있을 것 같습니다.
지금처럼 단순한 로직에서는 큰 문제가 없어 보이지만, 복잡한 코드에서는 신경 써야 할 것 같습니다~!