Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

[2023-09-27] jisu #269 #287

Merged
merged 2 commits into from
Oct 1, 2023
Merged

[2023-09-27] jisu #269 #287

merged 2 commits into from
Oct 1, 2023

Conversation

zsmalla
Copy link
Contributor

@zsmalla zsmalla commented Sep 28, 2023

PR Summary

풀이 시작 : 2023-09-27 10:28

제한 사항

N <= 100,000 이므로 O(NlogN) 이하의 알고리즘을 설계해야 한다.

풀이

  • 투 포인터로 접근 (low, high = 0, 0)
  • high 인덱스의 값이 현재 sub_set 집합에 없으면
    • sub_set 집합에 high 인덱스의 값을 add
    • 이후 high를 넓혀서 탐색
    • 경우의 수 1 증가
  • 집합에 이미 있는 경우 같은 수가 하나의 경우에 여러번 나타난 것
    • sub_set을 초기화 하고 low, high를 low+1로 초기화

풀이 중단 : 2023-09-27 11:00 (32분 경과)

풀이 재개 : 2023-09-27 14:30

풀이(스터디 이후)

  • low번째 인덱스부터 중복 없는 high인덱스까지의 경우의 수는 그 구간의 길이임
    • 예를 들어 1 2 3 1 2 에서 중복 없는 1 2 3 구간에서 1부터 시작하는 경우의 수는 1, 12, 123 => 3가지이므로 구간의 길이
  • 따라서 low로 순회하면서, high를 low와 중복되지 않는 인덱스까지 넓히며 탐색을 반복하면 된다.
    • 1 2 3 -> 2 3 1 -> 3 1 2 -> 1 2 -> 2 : 12개의 경우의 수
메모리 시간
44844KB 152ms

@zsmalla zsmalla added the BOJ label Sep 28, 2023
@zsmalla zsmalla self-assigned this Sep 28, 2023
@zsmalla zsmalla linked an issue Sep 28, 2023 that may be closed by this pull request
@zsmalla
Copy link
Contributor Author

zsmalla commented Sep 28, 2023

늦어서 죄송합니다..! 모두 중복 처리하는 부분이 조금씩 달라서 재미있는 풀이었지만 너무 미웠던 문제였네요 저한테는 ㅠㅠ

@limstonestone
Copy link
Contributor

역시 기존 접근법에서 크게 추가된 것 없이 풀어내셨네요 ㅎㅎ
고생하셨습니다 지수님 !!!

Copy link
Member

@Woo-Yeol Woo-Yeol left a comment

Choose a reason for hiding this comment

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

결국 풀이해내셨군요! 이런 문제는 사전에 풀이를 해보는 경험들이 참 중요한 것 같습니다! 고생하셨어요!

@zsmalla zsmalla merged commit 895c841 into main Oct 1, 2023
@zsmalla zsmalla deleted the jisu-#269 branch October 1, 2023 04:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BOJ] List of Unique Numbers
3 participants