Challenge: First Non-Repeating Integer in an Array

Given an array, find the first integer, which is unique in the array. Unique means the number does not repeat and appears only once in the whole array. Implement your solution in Java and see if it runs correctly!

Problem Statement #

In this problem, you have to implement the int findFirstUnique(int[] arr) method that will look for a first unique integer, which appears only once in the whole array. The function returns -1 if no unique number is found.

Method Prototype #

int findFirstUnique(int[] arr)

Output #

The first unique element in the array.

Sample Input #

arr = {9, 2, 3, 2, 6, 6}

Sample Output #


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