-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0310.py
More file actions
23 lines (23 loc) · 824 Bytes
/
0310.py
File metadata and controls
23 lines (23 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#https://school.programmers.co.kr/learn/courses/30/lessons/67258
#정확도는 100프로인데 효율성에서 0점이다....다른 알고리즘으로 풀어야겠다. 왜일까..ㅠㅠㅠㅠㅠㅠㅠㅠ물어봐야겠다
def solution(gems):
set1 = set(gems)
a = len(set1)
answer = []
for i in range(len(gems)):
count = 1
dic1 = {}
dic1[gems[i]] = i
for j in range(i+1,len(gems)):
if count != a:
if dic1.get(gems[j]) == None:
dic1[gems[j]] = j
count += 1
if count == a:
answer.append([i+1,j+1])
else:
continue
else:
answer.append([i+1,j])
answer.sort(key= lambda x:x[1]-x[0])
return answer[0]