Given an array of integers where every integer occurs three times except for one integer which only occurs once, find and return the non-duplicated integer. Do this in O(N) time and O(1) space.
Example 1:
Input: 7
6 1 3 3 3 6 6
Output: 1
Example 2:
Input: 4
13 19 13 13
Output: 19
Constraints:
1 <= n <= 10^5
-2^31 <= arr[i] <= 2^31 - 1
n = 3k + 1 for some integer k