Back to problems

First Unique Element IV

Algorithm · Apple · Easy

Given an integer array, return the earliest value that occurs exactly once. Return -1 when no value appears only one time. Input format: An array of n integers, with every value lying in the inclusive range [-10^9, 10^9]. Output format: Return the first element whose frequency is one. If every element has a duplicate occurrence, return -1. Example: Explanation: 9 is the first number in left-to-right order that occurs exactly once. Explanation: Both 8 and 6 repeat, while 1…

Checking your access…