Find Two Non-Repeating Elements Problem Statement

Given an array of integers ARR with size N, where exactly two elements appear only once and all others appear exactly twice, identify and return the two unique elements.

Input:

The first input line contains an integer N, the size of the array.
The second input line contains N space-separated integers representing the elements of the array.

Output:

Output two space-separated integers that appear only once, ensuring the first integer is smaller than the second.

Example:

Input:
N = 6
ARR = [2, 4, 6, 8, 4, 2]
Output:
6 8

Constraints:

  • 2 <= N <= 10^5
  • -10^5 <= ARR[i] <= 10^5
Note:
1. There will always be only two integers that appear exactly once, while the rest appear twice.
2. Aim to solve this problem in linear time and with constant space.
Be the first one to answer
Add answer anonymously...
TO THE NEW Technical Trainee Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter