Skip to content

[acious] WEEK 01 solutions#2364

Merged
acious merged 7 commits intoDaleStudy:mainfrom
acious:main
Mar 7, 2026
Merged

[acious] WEEK 01 solutions#2364
acious merged 7 commits intoDaleStudy:mainfrom
acious:main

Conversation

@acious
Copy link
Contributor

@acious acious commented Mar 2, 2026

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@github-actions github-actions bot added the kotlin label Mar 2, 2026
@acious acious changed the title [acious] WEEK 01 solutions [acious][DRAFT] WEEK 01 solutions Mar 2, 2026
@yerim01 yerim01 requested review from yerim01 March 3, 2026 00:35
@acious acious changed the title [acious][DRAFT] WEEK 01 solutions [acious] WEEK 01 solutions Mar 5, 2026
fun containsDuplicate(nums: IntArray): Boolean {
val set = HashSet<Int>()
for (num in nums) {
if (set.contains(num)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

코틀린에서도 contains를 쓰는군요 잘 보았습니다!

val complement = target - nums[index]
val complementIndices = map[complement]
if (complementIndices != null) {
for (complementIndex in complementIndices) {
Copy link
Contributor

@yerim01 yerim01 Mar 7, 2026

Choose a reason for hiding this comment

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

complementIndices를 순회 하는 부분에서 중첩 for loop 이 생기면서 time complexity가 O(n^2)이 될 수도 있을 것 같은데 제가 이해한게 맞을까요?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

이 complementIndices는 최대 사이즈가 2입니다. :)
그래서 n^2와 같은 성능으로 동작하진 않는다고 볼수 있습니다.

Copy link
Contributor

Choose a reason for hiding this comment

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

그렇군요 설명 감사합니다!

@@ -0,0 +1,19 @@
class Solution {
// 시간복잡도 : O(n) : map 세팅, O(nlogn) : map value 정렬 = O(nlogn)
fun topKFrequent(nums: IntArray, k: Int): IntArray {
Copy link
Contributor Author

@acious acious Mar 7, 2026

Choose a reason for hiding this comment

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

이건 성능이 꽤 나쁘게 책정되었는데 더 나은 솔루션을 시간이 없어서 적용하지 못했네요.

Copy link
Contributor

@yerim01 yerim01 left a comment

Choose a reason for hiding this comment

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

이번주도 수고하셨습니다! 다음주도 화이팅해요.

@acious acious merged commit 3d95690 into DaleStudy:main Mar 7, 2026
1 check passed
@github-project-automation github-project-automation bot moved this from Solving to Completed in 리트코드 스터디 7기 Mar 7, 2026
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.

2 participants