No Idea in python - HackerRank Solution
Problem :
Note: Since A and B are sets, they have no repeated elements. However, the
array might contain duplicate elements.
Constraints :
- 1 <= n <= 10^5
- 1 <= m <= 10^5
- 1 <= any integer in the input <= 10^9
Input Format :
The second line contains n integers, the elements of the array.
The third and fourth lines contain m integers, A and B, respectively.
Output Format :
Output a single integer, your total happiness.
Sample Input :
3 2 1 5 3 3 1 5 7
Sample Output :
1
Explanation :
Hence, the total happiness is 2 - 1 = 1.
Solution :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # No Idea in python - Hacker Rank Solution # Python 3 # Enter your code here. Read input from STDIN. Print output to STDOUT # No Idea in python - Hacker Rank Solution START io = input().split() m = int(io[0]) n = int(io[1]) storage = list() count = 0 storage = list(map(int, input().strip().split())) A = set(map(int, input().strip().split())) B = set(map(int, input().strip().split())) for i in storage: if i in A: count = count+1 if i in B: count = count-1 print(count) # No Idea in python - Hacker Rank Solution END |
Disclaimer :-
the above hole problem statement is given by hackerrank.com but the solution is generated by the codeworld19 authority if any of the query regarding this post or website fill the following contact form thank you.
if __name__ == '__main__':
nm = input().split()
n = int(nm[0])
m = int(nm[1])
arr = []
for _ in range(n):
arr.append(list(map(int, input().rstrip().split())))
k = int(input())
data = sorted(arr, key = lambda x: x[k])
for x in data:
for i in x:
print(i, end=" ")
print("")