[pepper] WEEK 2 Solution#363
Merged
whewchews merged 6 commits intoDaleStudy:mainfrom Aug 24, 2024
Merged
Conversation
Contributor
whewchews
commented
Aug 23, 2024
- Valid Anagram #218
- Counting Bits #233
- Encode and Decode Strings #238
- Construct Binary Tree From Preorder And Inorder Traversal #253
- Decode Ways #268
DaleSeo
reviewed
Aug 23, 2024
Comment on lines
+12
to
+13
| count[sChar] = (count[sChar] || 0) + 1; | ||
| count[tChar] = (count[tChar] || 0) - 1; |
Member
There was a problem hiding this comment.
nit: 이 문제의 경우 무방하지만, 일반적으로는 || 대신에 ??를 사용하는 것이 더 안전하지 않을까 생각이 들었습니다.
Suggested change
| count[sChar] = (count[sChar] || 0) + 1; | |
| count[tChar] = (count[tChar] || 0) - 1; | |
| count[sChar] = (count[sChar] ?? 0) + 1; | |
| count[tChar] = (count[tChar] ?? 0) - 1; |
Contributor
Author
There was a problem hiding this comment.
감사합니다! 말씀해주신대로 ?? 을 사용하는게 좋을 것 같습니다.
이런 코드에서는 원하는 값이 없는 경우에, 기본값을 사용할 목적이니 JS의 falsy한 값을 모두 처리하는 ||(논리OR연산자)가 아닌 null이나 undefined 값만 처리하는 ??(널병합연산자) 를 사용하는게 더 목적에 맞고 안전하게 처리해줄 수 있겠네요!
Member
|
@whewchews 님, Week 설정을 안 해주셔서 이번 주 풀이로 안 잡히셨더라고요. 다음 PR 부터 Week 설정 좀 꼭 부탁드리겠습니다. |
Contributor
Author
|
네, Week 체크하겠습니다! |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
