Repeating Elements
Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive)
Input : [8,8,7,5,6,2,1,7,5]
Output:
8
7
5
def printRepeating(arr, size): print("The repeating elements are: ") for i in range(0, size): if arr[abs(arr[i])] >= 0: arr[abs(arr[i])] = -arr[abs(arr[i])] else: print(abs(arr[i])) arr = list(map(int,input("Elements : ").split(' '))) #or arr=[8,8,7,5,6,2,1,7,5] arr_size = len(arr) printRepeating(arr, arr_size)
Input_1:
Elements : 8 8 7 5 6 2 1 7 5
Output:
The repeating elements are:
8
7
5
Input_2:
Elements : 7 5 7 6 2 1 5 6
Output:
The repeating elements are:
7
5
6
Input_3:
Elements : 1 2 3 1 2 4 6
Output:
The repeating elements are:
1
2
Input_4:
Elements : 0 1 0 3 3 5
Output:
The repeating elements are:
3
Illustration of the Output:
![](http://www.fcukthecode.com/wp-content/uploads/2021/12/Screenshot-from-2021-12-05-11-46-33.png)
More Q
- Determine if a person could attend all meetings in given interval times.
- Find the volume of a volley ball
- Find the maximum score obtained at the end of colour chess grid game.
- Find the number of pairs if positive integers with condition is even.
- Return the largest subset such that every pair meets the given condition.
- Find the number of index triplets that satisfy given condition.
- Handling multiple queries using array – sum, update, range.
- Find all the sequences that occur more than once in DNA molecule.
- Find the biggest number.
- Sum of cube of each number is again equal to the number then it is an Armstrong number.
- Hello World.
- Calculate the Cube Root.
- Find the count of consecutive 1’s present in array.
- Return an array with athletes relative ranks according to the score.
- Return a string of its base 7 representation.
- Return kth largest element in sorted order.
- Find all repeated elements in the array.
- Find atleast one duplicate number in the array.
- Find the maximum result of = a XOR b.