Skip to content

Commit

Permalink
Merge pull request #56 from AlgoLeadMe/11-fnzksxl
Browse files Browse the repository at this point in the history
11-fnzksxl
  • Loading branch information
fnzksxl authored Mar 16, 2024
2 parents e8d2065 + ce7a1fe commit 9333369
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions fnzksxl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
| 8์ฐจ์‹œ | 2024-02-20 | DP | [๋™์ „1](https://www.acmicpc.net/problem/2293) | [#32](https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/32) |
| 9์ฐจ์‹œ | 2024-02-23 | ๊ทธ๋ž˜ํ”„ | [์ˆœ์œ„](https://school.programmers.co.kr/learn/courses/30/lessons/49191) | [#37](https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/37) |
| 10์ฐจ์‹œ | 2024-03-07 | ๊ตฌํ˜„ | [๋‚˜๋ฌด ์žฌํ…Œํฌ](https://www.acmicpc.net/problem/16235) | [#52](https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/52) |
| 11์ฐจ์‹œ | 2024-03-10 | ํˆฌํฌ์ธํ„ฐ | [๋ณด์„ ์‡ผํ•‘](https://school.programmers.co.kr/learn/courses/30/lessons/67258) | [#56](https://github.com/AlgoLeadMe/AlgoLeadMe-6/pull/56) |
---
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
def solution(gems):
answer = []
head, tail = 0, 0
gem_length = len(set(gems))
gems_dict = {}
gem_min = len(gems) + 1

while head <= tail < len(gems):
gems_dict[gems[tail]] = gems_dict.get(gems[tail], 0) + 1
tail+=1

if len(gems_dict) == gem_length:
while head < tail:
if gems_dict[gems[head]] > 1:
gems_dict[gems[head]] -= 1
head += 1

elif gem_min > tail - head:
gem_min = tail - head
answer = [head+1, tail]
break

else:
break

return answer

0 comments on commit 9333369

Please sign in to comment.