Sobes.tech
Intern — Middle

Finding the singular number in an array

livecode

Task condition

Given an array arr containing an odd number of integers. Each value appears exactly twice, except for one — the only one that appears only once. Determine and return this single number.

void findUnique(const std::vector<int>& arr) {
    // find the element that appears once
}

Example:

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