Challenge: First Non-Repeating Integer in an Array

Given an array, find the first integer which is unique in the array using hashing technique. 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) function that will look for a first unique integer which appears only once in the whole array. You must use hashing to implement this function in the most optimized way possible.

Note: We consider zero to be an integer for the premise of this challenge.

Function Prototype

int findFirstUnique(int[] arr)

Output

The first unique element in the array.

Sample Input

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

Sample Output

9

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