Find Unique Elements
Updated
Problem statement
You are given an integer array nums. Return all elements that appear exactly once in nums, in the order they appear in nums.
If no element appears exactly once, return an empty array.
Function
findUniqueElements(nums: int[]) → int[]Examples
Example 1
nums = [4,3,4,1,2,3]return = [1,2]4 and 3 each appear twice. 1 and 2 appear once, so the answer is [1, 2] in the order they appear.
Example 2
nums = [7,7,7]return = []7 appears three times, so no element appears exactly once. The answer is an empty array.
Example 3
nums = [-5,0,5]return = [-5,0,5]Every element appears once, so all of them are returned in their original order.
Constraints
1 <= nums.length <= 2000-10^5 <= nums[i] <= 10^5
More Cisco interview questions
- Check if a String Is a PalindromePHONE 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
- Longest Non-Repeating SubstringPHONE SCREEN · Seen Jul 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
- Fixed-Range Frequency CountWaymo · PHONE SCREENWaymo interview questions
- Count Pairs with Absolute Difference KAdobe · PHONE SCREENAdobe interview questions
- Frequency Equals Card ValueInMobi · PHONE SCREENInMobi interview questions
- Pair Left and Right Shoes by SizeMotive · PHONE SCREENMotive interview questions
- Do All Frequencies Exceed a Threshold?Google · PHONE SCREENGoogle interview questions
- Apply Operations to Make a String EmptyFlexport · PHONE SCREENFlexport interview questions
- Find Valid SET Card TriplesSnowflake · OA · PHONE SCREENSnowflake interview questions
- Best Poker Category with a JokerScale AI · PHONE SCREEN · ONSITE INTERVIEWScale AI interview questions
- Find All Zip Rummy MeldsZip · PHONE SCREEN · ONSITE INTERVIEWZip interview questions
- Most Common Three-Website SequencesAmazon · PHONE SCREEN