Given a non-empty array of integers, every element appears twice except for one. Find that single one.
Input : Array = [7,1,2,3,1,2,3]
Output : 7
#use for loop if necessary Arr = list(map(int,input('Enter the array elements : ').split(' '))) temp=0 for i in range(len(Arr)): temp=temp^Arr[i] # using Xor operator print('Minimum - ',temp)
Input_1:
Enter the array elements : 1 2 3 7 1 2 3
Output:
Minimum – 7
Input_2:
Enter the array elements : 7 8 9 6 7 8 9
Output:
Minimum – 6
Input_3:
Enter the array elements : 20 25 30 20 30
Output:
Minimum – 25
Input_4:
Enter the array elements : 9 6 3 2 9 3 6
Output:
Minimum – 2
Input_5:
Enter the array elements : 7 4 1 2 2 4 7
Output:
Minimum – 1
ILLUSTRATION OF THE OUTPUT
More Q
- Find the majority element appearing more than n/2 times
- Return an array of the squares of each number.
- Highest factor in addition.
- Find the empty packets(0) of chocolate and push it to the end of the conveyor belt(array).
- Every element in array appears twice.Find that single one.
- Find the duplicate letters in string. Same to do in dictionary way.
- Find minimum number of edits (operations) required to convert ‘str1’ into ‘str2’.
- Return the maximum number you can get by changing at most one digit.
- Sed Commands – Ranges of lines.
- Find the kth smallest element in the given 2D array.
- Find all elements that appear more than [n/3] times.
- Write a function to return true if s2 contains the permutation of s1.
- Sort the array into a wave like array.
- Re-order array, such that
nums[0] < nums[1] > nums[2] < nums[3]...
. - Given the coordinates, return true if the four points construct a square.
- Minimum Distance Between Words of a String.
- Return the shortest distance between these two words.
- Write a program to find the n-th ugly number.
- Check if array could become Non – Decreasing array.
- Find the minimum area of a rectangle that can be formed from given points.