Ray, Shiv and Ansh are conducting a survey for a group of people. The survey is only meant for twins but there are certain people who are not twins and wanting to take part in the survey.
Write an algorithm to help them identify the person from the given input who is not a twin.
Input
The first line of input consists of an integer- inputArr_size, representing the number of entries in the array (N). The next line consists of N space-separated integer elements in the array.
Output
Print the smallest value of the person who is not a twin from the given array of elements.
Note: If everyone present is a twin, then return -1.
⋆。‧˚Credit to Charlotte ʚɞ˚‧。⋆。ꪆৎ ˚⋅
inputArr = [1, 1, 2, 3, 3, 4, 4] return = 2
In the given array of element, only non-twin element is '2'. So, the output is 2.
inputArr = [1, 1, 2, 2] return = -1
Given array of element contain all the twin elements. So, the output is -1.
🍋🟩🍋🟩- Collect CoinsSeen Jun 2025
- FizzBuzz ProblemSeen May 2025
- Find Largest Sum Contiguous SubarraySeen May 2025
- Find Largest Sum of Continuous SequenceSeen May 2025
- Find Palindrome Sub-stringSeen May 2025
- Flight Path Package DropSeen May 2025
- Count Numbers with Digit SumSeen Mar 2025
- Maximum Chocolates from Jars (L.C. 198 :)Seen Mar 2025
public int identifyNonTwinPerson(int[] inputArr) {
// write your code here
}