We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
# Determine the range of numbers in the input arrays
min_num = min(arr + brr)
max_num = max(arr + brr)
# Initialize count arrays with zeros
count_arr = [0] * (max_num - min_num + 1)
count_brr = [0] * (max_num - min_num + 1)
# Count occurrences of numbers in arr and brr
for num in arr:
count_arr[num - min_num] += 1
for num in brr:
count_brr[num - min_num] += 1
# Find the missing numbers
missing = []
for i in range(len(count_arr)):
if count_arr[i] < count_brr[i]:
missing.append(i + min_num)
# Ensure the difference between max and min is less than 100
if missing and max(missing) - min(missing) >= 100:
return []
return sorted(missing)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Missing Numbers
You are viewing a single comment's thread. Return to all comments →