Skip to content

[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

Merged
merged 9 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions contains-duplicate/suhacs.js
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;
Copy link
Contributor

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

이후로도 더 간략화 할 수 있어 보이는데, 혹시 시간이 가능하시다면 한번 해보시는건 어떨까요?

Copy link
Contributor Author

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;
}

이렇게 하니까 더 간단해지네요..!!!피드백 감사합니다~~!

}
console.log(containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제출시에는 확인을 위한 로그는 제거해주시는게 좋을 것 같아요! 🧹

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 알겠습니다 !!

//
14 changes: 14 additions & 0 deletions top-k-frequent-elements/suhacs.js
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]);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

풀이의 일부가 누락된 것 같아요. 혹시 다시 확인 해 주실 수 있나요?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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);
12 changes: 12 additions & 0 deletions valid-palindrome/suhacs.js
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(" ", "")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.replaceAll(/[^a-zA-Z0-9]/g, "")에서 이미 충분하게 replaceAll(" ", "")까지 처리될것으로 보여요

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네 피드백 감사합니다 !!

.toLowerCase();
console.log(refinedTxt === [...refinedTxt].reverse().join("") ? true : false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

불필요한 로그네요! 🧹

return refinedTxt === [...refinedTxt].reverse().join("") ? true : false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return refinedTxt === [...refinedTxt].reverse().join("")로 충분해 보입니다!

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
Loading