Repository: TheAlgorithms/C-Plus-Plus
File: bit_manipulation/find_non_repeating_number.cpp (C++)

Code before:
 * @brief Implementation to find the non repeating integer
 * in an array of repeating integers. [Single
 * Number](https://leetcode.com/problems/single-number/)
 *
 * @details
 * Given an array of integers in which all of the numbers occur exactly
 * twice except one integer which occurs only once. Find the non-repeating
 * integer.
 *
 * Worst Case Time Complexity: O(n)
 * Space complexity: O(1)

 * @author [Ravidev Pandey](https://github.com/literalEval)
 */

#include <cassert>   /// for assert
#include <iostream>  /// for IO operations
#include <vector>    /// storing the numbers

/**
 * @namespace bit_manipulation
 * @brief Bit manipulation algorithms
 */
namespace bit_manipulation {
/**
 * @namespace setKthBit
 * @brief Functions to find the non repeating integer
 * in an array of repeating integers. [Single
 * Number](https://leetcode.com/problems/single-number/)
 */
namespace find_single_number {
/**
 * @brief The main function implements find single number
 * @param nums vector of integers
 * @returns returns the integer that occurs only once
 */
int find_single_number(std::vector<int>& nums) {
    // The idea is based on the property of XOR.
    // We know that 'a' XOR 'a' is '0' and '0' XOR 'b'
    // is b.
    // Using this, if we XOR all the elements of the array,
    // the repeating elements will give '0' and this '0'
    // with the single number will give the number itself.

    int _xor = 0;

    for (const int& num: nums) {
        _xor ^= num;
    }

    return _xor;

Review comment (suggestion):
```suggestion
 * @namespace find_single_number
```


Code after:
 * @brief Implementation to find the non repeating integer
 * in an array of repeating integers. [Single
 * Number](https://leetcode.com/problems/single-number/)
 *
 * @details
 * Given an array of integers in which all of the numbers occur exactly
 * twice except one integer which occurs only once. Find the non-repeating
 * integer.
 *
 * Worst Case Time Complexity: O(n)
 * Space complexity: O(1)

 * @author [Ravidev Pandey](https://github.com/literalEval)
 */

#include <cassert>   /// for assert
#include <iostream>  /// for IO operations
#include <vector>    /// storing the numbers

/**
 * @namespace bit_manipulation
 * @brief Bit manipulation algorithms
 */
namespace bit_manipulation {
/**
 * @namespace find_non_repeating_integer
 * @brief Functions to find the non repeating integer
 * in an array of repeating integers. [Single
 * Number](https://leetcode.com/problems/single-number/)
 */
namespace find_non_repeating_integer {
/**
 * @brief The main function implements find single number
 * @param nums vector of integers
 * @returns returns the integer that occurs only once
 */
int64_t find_non_repeating_integer(const std::vector<int>& nums) {
    // The idea is based on the property of XOR.
    // We know that 'a' XOR 'a' is '0' and '0' XOR 'b'
    // is b.
    // Using this, if we XOR all the elements of the array,
    // the repeating elements will give '0' and this '0'
    // with the single number will give the number itself.

    int _xor = 0;

    for (const int& num: nums) {
        _xor ^= num;
    }

    return _xor;