-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfytq_coding_april19.py
More file actions
60 lines (47 loc) · 1.3 KB
/
infytq_coding_april19.py
File metadata and controls
60 lines (47 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
s=list(map(int,input().split(",")))
from collections import Counter
re=[]
def printRepeating(arr, size):
re=[]
for i in range (0, size):
for j in range (i + 1, size):
if arr[i] == arr[j]:
re.append(arr[i])
return(re)
for i in range(len(s)):
val=-355
temp=[]
temp.clear()
temp=s[i+1:len(s)].copy()
temp.sort()
result=temp.copy()
result = [item for items, c in Counter(temp).most_common()
for item in [items] * c]
if(len(result)!=len(set(result)) and len(result)!=0):
val1=printRepeating(result,len(result))
count=-1
max1=-4500
for j in val1:
if(j>s[i]):
count1=result.count(j)
if(count1>count):
count=count1
max1=j
elif(count1==count):
max1=min(max1,j)
val=max1
if(max1==-4500):
val=-1
else:
for j in result:
if(j>s[i]):
val=j
break
else:
val=-1
if(len(result)==0):
val=-1
re.append(val)
result.clear()
re=list(map(str,re))
print(",".join(re))