Challenge 6: Finding the First Unique Integer in an Array

This challenge provides an array. Find the first integer, which is unique in the array.

Problem statement

Implement a function findFirstUnique(int arr[], int size), which takes an array and its size as input and returns the first unique integer in the array. The function returns -1 if no unique number is found. “Unique” means the number does not repeat and appears only once in the whole array.

Input

An array of integers and its size is the input.

Output

The first unique element in the array is the output.

Sample input

[2,3,9,2,3,6]

Sample output

9

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.