-
-
Notifications
You must be signed in to change notification settings - Fork 247
[phenomenal_star_75309] #677
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
Changes from all commits
7fe96f4
5c3e525
892a279
f909bb4
d1fbcfb
de55a70
947ca5b
f398dca
958eaf1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
function containsDuplicate(nums) { | ||
const setLength = [...new Set(nums)].length; | ||
const numLength = nums.length; | ||
return numLength === setLength ? false : true; | ||
} | ||
console.log(containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2])); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 제출시에는 확인을 위한 로그는 제거해주시는게 좋을 것 같아요! 🧹 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 알겠습니다 !! |
||
// |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. | ||
|
||
function top_k_frequent_element(numArr, k) { | ||
let element_qty = []; | ||
const numSet = [...new Set(numArr)]; | ||
for (num of numSet) { | ||
const count = numArr.filter((x) => x === num).length; | ||
element_qty.push({ [num]: count }); | ||
} | ||
Object.keys(element_qty).forEach((key) => element_qty[key]); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 풀이의 일부가 누락된 것 같아요. 혹시 다시 확인 해 주실 수 있나요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 회사에서 시간날때 풀다가, 집에서 마저 풀려고 커밋 해놓은건데 미완성인 상태로 올려버렸네요. 다음부터 유의하겠습니다 ! |
||
|
||
const Arr = [1, 2, 3, 4, 5, 5, 5, 5, 3, 3, 32, 2, 2, 1]; | ||
top_k_frequent_element(Arr); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
function isValidPalindrome(text) { | ||
let refinedTxt = text | ||
.replaceAll(/[^a-zA-Z0-9]/g, "") | ||
.replaceAll(" ", "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 네 피드백 감사합니다 !! |
||
.toLowerCase(); | ||
console.log(refinedTxt === [...refinedTxt].reverse().join("") ? true : false); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 불필요한 로그네요! 🧹 |
||
return refinedTxt === [...refinedTxt].reverse().join("") ? true : false; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 그렇네요 감사합니다 !! |
||
} | ||
|
||
isValidPalindrome("A man, a plan, a canal: Panama"); //true | ||
isValidPalindrome("race a car"); //false | ||
isValidPalindrome(" "); //true |
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.
2line:
new Set(nums).size !== nums.length
4line:
numLength !== setLength
이후로도 더 간략화 할 수 있어 보이는데, 혹시 시간이 가능하시다면 한번 해보시는건 어떨까요?
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.
function containDuplicate2(nums) {
return nums.length !== new Set(nums).size;
}
이렇게 하니까 더 간단해지네요..!!!피드백 감사합니다~~!