Created
July 21, 2021 14:09
-
-
Save ItsFaynn/aafada539b0c9ddfcd70f0c87e2ee8e9 to your computer and use it in GitHub Desktop.
Missing Numbers HackerRank python3 solution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Faynn | |
#!/bin/python3 | |
import math | |
import os | |
import random | |
import re | |
import sys | |
from collections import Counter | |
# | |
# Complete the 'missingNumbers' function below. | |
# | |
# The function is expected to return an INTEGER_ARRAY. | |
# The function accepts following parameters: | |
# 1. INTEGER_ARRAY arr | |
# 2. INTEGER_ARRAY brr | |
# | |
def missingNumbers(arr, brr): | |
# Write your code here | |
brr_counter = Counter(brr) | |
arr_Counter = Counter(arr) | |
output = brr_counter - arr_Counter | |
return sorted(list(output.keys())) | |
if __name__ == '__main__': | |
fptr = open(os.environ['OUTPUT_PATH'], 'w') | |
n = int(input().strip()) | |
arr = list(map(int, input().rstrip().split())) | |
m = int(input().strip()) | |
brr = list(map(int, input().rstrip().split())) | |
result = missingNumbers(arr, brr) | |
fptr.write(' '.join(map(str, result))) | |
fptr.write('\n') | |
fptr.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment