Skip to content

Conversation

gmlwls96
Copy link
Contributor

@gmlwls96 gmlwls96 commented Dec 29, 2024

답안 제출 문제

체크 리스트

  • 우측 메뉴에서 PR을 Projects에 추가해주세요.
  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

@gmlwls96 gmlwls96 requested a review from KwonNayeon December 29, 2024 02:52
@gmlwls96 gmlwls96 requested a review from a team as a code owner December 29, 2024 02:52
@DaleSeo
Copy link
Member

DaleSeo commented Dec 29, 2024

@gmlwls96 님, 프로젝트 주차 설정 좀 부탁드리겠습니다. (참고: 답안 제출 가이드)

Shot 2024-12-29 at 07 41 02

intArrayOf(0, 1)
)

fun exist(board: Array<CharArray>, word: String): Boolean {
Copy link
Member

@DaleSeo DaleSeo Dec 31, 2024

Choose a reason for hiding this comment

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

만약에 board[["a"]]로 주어지고, word"a"로 주어진다면 어떨까요?

* 1. 모든 substring을 전부 뽑아낸다.
* 2. 해당 substring이 palindrome인지 체크한다.
*/
// 시간 : O(n^3)
Copy link
Member

Choose a reason for hiding this comment

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

깔끔한 풀이지만 실제 면접에서는 시간 복잡도에 대해서 챌린지를 받으실 수 있으실 것 같아요. 아직 마감까지 시간이 많으니 더 효율적인 알고리즘도 고민해보시면 좋을 것 같습니다.

Copy link
Member

Choose a reason for hiding this comment

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

이 풀이만 복잡도 표기를 누락하신 것 같네요. (의도하신 게 아니라면요)

Comment on lines +18 to +25
currentList1 == null -> {
answerList.offer(currentList2!!.`val`)
currentList2 = currentList2.next
}
currentList2 == null -> {
answerList.offer(currentList1.`val`)
currentList1 = currentList1.next
}
Copy link
Member

@DaleSeo DaleSeo Dec 31, 2024

Choose a reason for hiding this comment

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

여기서 왜 currentList2 상대로만 non-null assertion이 필요한 건가요? 🤔

@KwonNayeon
Copy link
Contributor

안녕하세요! 내일 오후까지 리뷰 남기도록 하겠습니다. 자세한 풀이 감사합니다. Kotlin 언어는 처음인데, 리뷰하면서 많이 배울 것 같습니다 :)

Comment on lines +8 to +25
fun coinChange(coins: IntArray, amount: Int): Int {
val initValue = Int.MAX_VALUE / 2
val dp = IntArray(amount + 1) { initValue }
dp[0] = 0
for (i in 1..amount) {
coins.forEach { c ->
if (c <= i) {
dp[i] = min(dp[i - c] + 1, dp[i])
}
}
}
return if (dp[amount] == initValue) {
-1
} else {
dp[amount]
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

아직 이 문제를 풀지 못했는데, 파이썬에서 sys.maxsize // 2를 초기값으로 설정하면, 오버플로우를 방지할 수 있다는 아이디어를 얻었어요. 문제를 풀 때 이 방식을 사용해봐야겠습니다. 이번주도 고생하셨습니다!

Comment on lines +1 to +13
class Solution {
fun missingNumber(nums: IntArray): Int {
nums.sort()
var num = nums[0]
for (i in 1 until nums.size) {
if (nums[i] != (num + 1)) {
return num + 1
}
num = nums[i]
}
return num + 1
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

저는 nums[i]를 i와 비교하는 방식을 사용했는데, @gmlwls96 님처럼 이전 값과 현재 값의 차이를 비교하는 방식도 있다는 걸 배웠어요. 이 방식으로도 문제를 풀어봐야겠습니다 😊

@gmlwls96 gmlwls96 merged commit 96f9b46 into DaleStudy:main Jan 5, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants