Solution to Odd-Occurrences-In-Array by codility

18 Sep

Question: https://codility.com/programmers/task/odd_occurrences_in_array

Question Name: Odd-Occurrences-In-Array or OddOccurrencesInArray

This question is completely the same as the Perm-Missing-Elem by codility. The comment from Kim is very helpful.

41 Replies to “Solution to Odd-Occurrences-In-Array by codility

  1. JavaScript solution
    Why I am getting only 11% for correctness?

  2. My Java solution (100%)

  3. I’m quite new to programming but here’s my python solution. I didn’t realise I could have used XOR.

  4. Mi Javascript Solution 100%

  5. My very simple Java solution (100%).

  6. This is my solution in python

    I got a 100% score

  7. Does anyone know what the ^= means? The Perm-Missing-Elem by codility post that keeps being references does not explain this.

  8. In PHP 100% To All 😀

  9. I see lots of solutions that call sort but the standard sorts are comparison sorts and have run time O(N logN). The question asks for O(N). That they pass the test indicates that the system is unable to distinguish O(N) and O(N log N) but I don’t believe they are correct per the instructions.

  10. I have the following solution:

    but have only Correctness 80% because of the error during check:

    And this errors occurs everytime…

    Can somebody explain what is the issue in my solution?
    Thanks in advance!

  11. Another in Python, using set:

  12. Hallo. This is my C++ version. I am not sure, I get 100% but I am wondering if it is 100% bug-proof. I modify the python version of @Ty.

    And yes this is O(N logN) . I am wondering if is it possible to obtain something similar to the one of @Ivan Padron .

    • >> catch (exception& e) // I am not sure of this part
      It’s used to catch the odd occurrence, when the largest number occurs for odd number of times.

Leave a Reply

Your email address will not be published. Required fields are marked *

Please put your code into a <pre>YOUR CODE</pre> section. Thanks and Happy Coding!