Skip to content

[phenomenal_star_75309] Week 2 #736

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 6 commits into from
Dec 22, 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: 5 additions & 2 deletions contains-duplicate/suhacs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@ function containsDuplicate(nums) {
const numLength = nums.length;
return numLength === setLength ? false : true;
}
console.log(containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2]));
//
//New function after feedback

function containDuplicate2(nums) {
return nums.length !== new Set(nums).size;
}
12 changes: 9 additions & 3 deletions top-k-frequent-elements/suhacs.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ function top_k_frequent_element(numArr, k) {
element_qty.push({ [num]: count });
}
Object.keys(element_qty).forEach((key) => element_qty[key]);
}

const Arr = [1, 2, 3, 4, 5, 5, 5, 5, 3, 3, 32, 2, 2, 1];
top_k_frequent_element(Arr);
const sortedArray = element_qty.sort((a, b) => {
const valueA = Object.values(a)[0];
const valueB = Object.values(b)[0];
return valueB - valueA;
});

const topKeys = sortedArray.slice(0, k).map((obj) => Object.keys(obj)[0]);
return topKeys;
}
7 changes: 7 additions & 0 deletions valid-anagram/suhacs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
function isValidAnagram(s, t) {
let temp = t;
for (char of s) {
temp = temp.replace(char, "");
}
return temp === "";
Comment on lines +2 to +6
Copy link
Contributor

Choose a reason for hiding this comment

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

t를 그대로 사용 안하시고 temp로 사용하신 이유가 있을지 궁금합니다 :)

}
Loading