-
-
Notifications
You must be signed in to change notification settings - Fork 195
[이유진] Week1 #674
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
[이유진] Week1 #674
Conversation
@Real-Reason 혹시 풀려고 했던 문제들을 모두 푼 상태이신가요? |
아, 이번주는 체크된 문제들까지 풀려고 했습니다 :) |
class SolutionContainsDuplicate { | ||
fun containsDuplicate(nums: IntArray): Boolean { | ||
val size = nums.size | ||
val numsToSet = nums.toSet() |
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.
안녕하세요 ^^
이 부분은 Set으로 중복 값을 제거하신거군요!
풀이가 간결해서 좋아보입니다 👍
cnt++ | ||
} | ||
else if (nums[i - 1] == nums[i]) { | ||
return@forEachIndexed |
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.
제가 kotlin 을 잘 몰라서 질문드립니다 😅 이 부분은 어떠한 작업인가요?
인덱스를 건너뛰는 작업인걸가요? ^^
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.
와, 신기한 코드네요 ㅋㅋ 저도 궁금합니다!
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.
forEach 문으로 return 해줍니다~
말씀해주신대로 해당 인덱스를 건너뛰는 의도로 작성했습니다 :)
var startIndex = 0 | ||
var endIndex = sToCharArray.size - 1 | ||
while (startIndex < endIndex) { | ||
if (!sToCharArray[startIndex].isLetterOrDigit() || sToCharArray[startIndex].isWhitespace()) { |
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.
이 부분은 글자 부분인지 확인하는 if문으로 보이는데요~
앞단에서 특수문자, 공백을 제거하는것도 좋을것 같습니다! ^^
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.
흠... 🤔 코드는 좀 더 복잡해도 저는 현재 방법이 더 효율적일 수 있다는 생각이 들어요. 앞단에서 특수문자, 공백을 제거하려면 입력 문자열을 2번 스캔해야하니까요. 물론 대세(빅오 표현법 상으로는)에는 지장이 없겠지만요 😄
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.
오늘 1주차 마감일이고 목표로 하신 4문제를 다 잘 푸신 것 같아서 PR 병합이 가능하시도록 우선 승인을 해드리겠습니다!
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.