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.
for i in range(1,max+1):
condition_1_flag = 0
condition_2_flag = 0
for item in a:
if i%item == 0:
condition_1_flag+=1
if condition_1_flag == len(a):
numbers_between.append(i)
for item in b:
if item%i == 0:
condition_2_flag+=1
if condition_2_flag == len(b):
numbers_between.append(i)
numbers_between.sort()
# Count occurrences of each number
for num in arr:
if num in count_dict:
count_dict[num] += 1
else:
count_dict[num] = 1
# Find numbers that are repeated
for num, count in count_dict.items():
if count > 1:
repeated_numbers.append(num)
return len(repeated_numbers)
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Between Two Sets
You are viewing a single comment's thread. Return to all comments →
def getTotalX(a, b): numbers_between = [] condition_1_flag = 0 condition_2_flag = False main_list = a+b max = max(main_list)
def find_repeated_numbers(arr): count_dict = {} repeated_numbers = []