Skip to content
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

[highball] week2 solutions #371

Merged
merged 1 commit into from
Aug 25, 2024
Merged

[highball] week2 solutions #371

merged 1 commit into from
Aug 25, 2024

Conversation

Copy link
Contributor

@DaleSeo DaleSeo left a comment

Choose a reason for hiding this comment

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

수고하셨습니다. Encode and Decode Strings 문제의 솔루션에 대해서 피드백 드렸습니다. 다음 PR 부터는 프로젝트 설정(Status, Week) 꼭 좀 부탁드리겠습니다.

@@ -0,0 +1,9 @@
const encode = function (arr) {
const encodedStr = arr.reduce((acc, cur) => acc + "#" + cur);
Copy link
Contributor

Choose a reason for hiding this comment

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

문제에서 입력 문자열에 256개의 ASCII 문자가 들어있을 수 있다고 했는데요. #도 ASCII 문자여서 입력 문자열에 #에 포함되어 있는 경우 문제가 될 수 있을 것 같습니다.

Copy link
Contributor

@tolluset tolluset left a comment

Choose a reason for hiding this comment

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

고생하셨슴당!

@@ -0,0 +1,9 @@
const encode = function (arr) {
const encodedStr = arr.reduce((acc, cur) => acc + "#" + cur);
Copy link
Contributor

@tolluset tolluset Aug 24, 2024

Choose a reason for hiding this comment

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

arr.join('#') 도 가능하겠네용! 달레님 코멘트처럼 아스키문자를 피해야 될 것 같아여!

tCharCount[charAsInt]++;
});

return sCharCount.reduce((acc, cur, i) => acc && cur === tCharCount[i], true);
Copy link
Contributor

Choose a reason for hiding this comment

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

sCharCount.every((count, i) => count === tCharCount[i]); 

로 확인할 수도 있겠네용!

검증이라면 every로 모든 값이 일치하는게 메소드가 조금 더 어울리는 것 같아여!

Comment on lines +5 to +13
Array.from(s).forEach((char) => {
const charAsInt = char.charCodeAt(0) - 97;
sCharCount[charAsInt]++;
});

Array.from(t).forEach((char) => {
const charAsInt = char.charCodeAt(0) - 97;
tCharCount[charAsInt]++;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

s와 t의 길이가 같지 않으면 anagram이 아니기 때문에 early retrun 하고 하나의 루프로 체크하는 것도 가능할 것 같아여!

Comment on lines +9 to +10
if (i % 2 === 0) arr[i] = arr[i / 2];
else arr[i] = arr[(i - 1) / 2] + 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

 arr[i] = i % 2 === 0 ? arr[i / 2] : arr[(i - 1) / 2] + 1;

특정 인덱스 값에 대입이어서 값에 대한 삼항으로 처리해도 좋을 것 같네영!

@highballplz highballplz merged commit 2712a2a into DaleStudy:main Aug 25, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants