Last active
September 16, 2022 08:42
-
-
Save Josephchinedu/63b7aad1a7b427db060823c69bc37485 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Description: | |
Given a non-empty array of integers, every element appears twice except one, find it | |
Steps: | |
1. Find the sum of the array | |
2. Find a unique element in the array | |
3. Find the sum of the unique element | |
4. Multiply the sum of the unique element by 2 | |
5. then minus sum of the array from the result of step 4 | |
Time complexity O(N): | |
We pass over the input array. | |
We do a separate over the set ones | |
space Complexity O(N) | |
Due to the usage of a set |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment