Every UPI payment in a list has a matching refund with the same id, so each id appears twice. One payment id has no refund and appears only once.
Given the non-empty array nums of ids, find the id that appears only once. Your solution must run in linear time and keep the extra memory constant.
Examples
Example 1:
Input: nums = [8,3,8]
Output: 3
Explanation: 8 appears twice, 3 appears once.
Example 2:
Input: nums = [5,9,5,7,9]
Output: 7
Explanation: 5 and 9 appear twice. 7 appears once.
Example 3:
Input: nums = [4]
Output: 4
Explanation: Only one id.