Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Input:[3 1 2 5 3]
- Output:[3, 4]
- A = 3, B = 4
- def repeated_number(number_array):
- pair_A_B = []
- n = len(number_array)
- for i in number_array:
- if(number_array.count(i)==2):
- pair_A_B.append(i)
- break
- sample = range(1,n+1)
- diff = list(set(sample)-set(number_array))
- pair_A_B.append(diff[0])
- return pair_A_B
- sample_input = [3,1,2,3,5]
- print(repeated_number(sample_input))
Add Comment
Please, Sign In to add comment