Identify the Non-Twin Person
Updated
Problem statement
You are given an array inputArr. Each element is the value of one person in a survey. Two people with the same value are twins, so a value that appears twice belongs to a pair of twins. A value that appears only once belongs to a person who is not a twin.
Return the smallest value that appears only once. If every value appears twice (everyone is a twin), return -1.
Function
identifyNonTwinPerson(inputArr: int[]) → intExamples
Example 1
inputArr = [1, 1, 2, 3, 3, 4, 4]return = 2In the given array of element, only non-twin element is '2'. So, the output is 2.
Example 2
inputArr = [1, 1, 2, 2]return = -1Given array of element contain all the twin elements. So, the output is -1.
Constraints
1 ≤ inputArr.length ≤ 10^50 ≤ inputArr[i] ≤ 10^9- Each value appears at most twice in
inputArr.
More Cisco interview questions
- Check if a String Is a PalindromePHONE SCREEN · Seen Nov 2026
- Find Unique ElementsPHONE SCREEN · Seen Nov 2026
- First Letter to Appear TwicePHONE SCREEN · Seen Nov 2026
- Middle of a Linked ListPHONE SCREEN · Seen Nov 2026
- Reverse a Linked ListPHONE SCREEN · Seen Nov 2026
- Reverse a StringPHONE SCREEN · Seen Nov 2026
- Valid ParenthesesPHONE SCREEN · Seen Nov 2026
- K-Step Bit Flip with RetentionPHONE SCREEN · Seen Nov 2026
- Todo Task Manager OperationsONSITE INTERVIEW · Seen Oct 2026
- Find the Duplicate Number Without Modifying the ArrayONSITE INTERVIEW · Seen Sep 2026
Similar questions at other companies
- Build the Task HierarchyPendo · OA
- Macaron Order with Set DiscountsShopify · OAShopify interview questions
- Count User Mentions in Chat MessagesRamp · OARamp interview questions
- Count Valid Square PairsAuxoAI · OA
- Two SumAmazon · OA · PHONE SCREEN
- Find Words That Can Be Formed by CharactersTabaPay · OA
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Word Frequency Counts in Alphabetical OrderAbridge · OAAbridge interview questions
- Customer Signer ScreeningState Farm · OA
- Minimum Magic Stones After MergesElevenLabs · OAElevenLabs interview questions