-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSorting
More file actions
70 lines (62 loc) · 1.57 KB
/
Copy pathSorting
File metadata and controls
70 lines (62 loc) · 1.57 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
61
62
63
64
65
66
67
68
#Monk and Nice Strings
def Niceness():
n = int(input())
s = []
for i in range(n):
k = input()
s.append(k)
j = i
while j > 0 and s[j] < s[j -1]:
(s[j] , s[j-1]) = (s[j-1],s[j])
j = j - 1
print(j)
def SuffixSort():
(s,k) = input().split()
k = int(k)
suffix_list = []
n = len(s)
for i in range(0,n):
suffix = s[i:]
suffix_list.append(suffix)
suffix_list.sort()
print(suffix_list[k-1])
def Monitor():
T = int(input())
ans = []
for i in range(T):
n = int(input())
arr = list(map(int, input().split()))
dicto = {}
for h in arr:
if h not in dicto.keys():
dicto[h] = 1
else:
dicto[h] = dicto[h] + 1
heights = sorted(dicto.keys())
diff = -1
for h in heights:
h_diff = dicto[h]
mini = min(list(dicto.values()))
maxi = max(list(dicto.values()))
ans.append(maxi-mini)
for _ in range(T):
print(ans[_])
def MonkSearch():
N = int(input())
ar = list(map(int,input().split()))
q = int(input())
answer = []
for queries in range(q):
qtyp,query = map(int,input().split())
count = 0
if qtyp == 0:
for num in ar:
if num >= query:
count += 1
else:
for num in ar:
if num > query:
count += 1
answer.append(count)
for _ in answer:
print(_)