Skip to content

Instantly share code, notes, and snippets.

@ItsFaynn
Created July 21, 2021 14:09
Show Gist options
  • Save ItsFaynn/aafada539b0c9ddfcd70f0c87e2ee8e9 to your computer and use it in GitHub Desktop.
Save ItsFaynn/aafada539b0c9ddfcd70f0c87e2ee8e9 to your computer and use it in GitHub Desktop.
Missing Numbers HackerRank python3 solution
# 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