Skip to content

Commit d512cd2

Browse files
.
1 parent c99889b commit d512cd2

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

10X/Python/Array/Interview.py

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'''
2+
Interview
3+
Description
4+
Microsoft has come to hire interns from your college. N students got shortlisted out of which few were males and a few females. All the students have been assigned talent levels. Smaller the talent level, lesser is your chance to be selected. Microsoft wants to create the result list where it wants the candidates sorted according to their talent levels, but there is a catch. This time Microsoft wants to hire female candidates first and then male candidates.
5+
6+
The task is to create a list where first all female candidates are sorted in a descending order and then male candidates are sorted in a descending order.
7+
8+
Input
9+
The first line contains an integer N denoting the number of students. Next, N lines contain two space-separated integers, ai and bi.
10+
11+
The first integer, ai will be either 1(for a male candidate) or 0(for female candidate).
12+
13+
The second integer, bi will be the candidate's talent level.
14+
15+
Output
16+
Output N space-separated integers, which first contains the talent levels of all female candidates sorted in descending order and then the talent levels of male candidates in descending order.
17+
18+
Example
19+
Input:
20+
21+
5
22+
23+
0 3
24+
25+
1 6
26+
27+
0 2
28+
29+
0 7
30+
31+
1 15
32+
33+
Output:
34+
35+
7 3 2 15 6
36+
37+
'''
38+
g=[]
39+
b=[]
40+
for _ in range(int(input())):
41+
x,y=map(int,input().split())
42+
if x==0:
43+
g.append(y)
44+
else:
45+
b.append(y)
46+
g.sort(reverse = True)
47+
b.sort(reverse = True)
48+
print(*g,end=" ")
49+
print(*b)

0 commit comments

Comments
 (0)