https://leetcode.com/problems/largest-unique-number

What we need to do is to apply counter and then find maximum element with frequency 1.

We can write it in the form of oneliner: find maximum and if it is empty, we return -1.

Complexity

Time complexity is O(n), we need to traverse our number just once. Space complexity is O(n) as well, because counter can have this size.

Code

class Solution:
    def largestUniqueNumber(self, A):
        return max([num for num, freq in Counter(A).items() if freq == 1] or [-1])

If you like the solution, you can upvote it on leetcode discussion section: Problem 1133