FastPrepIdentify the Non-Twin Person

Identify the Non-Twin Person

Cisco logoCisco● EasyINTERNOA
Learn

Problem statement

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.

Function

identifyNonTwinPerson(inputArr: int[]) → int

Examples

Example 1

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.

Example 2

inputArr = [1, 1, 2, 2]return = -1

Given array of element contain all the twin elements. So, the output is -1.

Constraints

  • 🍋‍🟩🍋‍🟩

More Cisco problems

See Cisco hiring insights
public int identifyNonTwinPerson(int[] inputArr) {
  // write your code here
}
inputArr[1, 1, 2, 3, 3, 4, 4]
expected2
Checking account…