Logo
Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Solution: Two Single Numbers

Problem Statement

In a non-empty array of numbers, every number appears exactly twice except two numbers that appear only once. Find the two numbers that appear only once.

Example 1:

Input: [1, 4, 2, 1, 3, 5, 6, 2, 3, 5]
Output: [4, 6]

Example 2:

Input: [2, 1, 3, 2]
Output: [1, 3]

Constraints:

  • 1 <= nums.length <= 3 * 10<sup>4</sup>
  • -3 * 10<sup>4</sup> <= nums[i] <= 3 * 10<sup>4</sup>
  • Each element in the array appears twice except for two element which appears only once.

Solution

This problem is quite similar to `Single Number

.....

.....

.....

Like the course? Get enrolled and start learning!