Last active
November 3, 2022 02:25
-
-
Save injust90/c930f8f85c83ab3335d7fc30419a30dc 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
int lonelyinteger(vector<int> a) { | |
int result = 0; | |
// for each element if result is equal to start of line then result is set to that value. | |
for (int i : a) | |
{ | |
result = result ^ i; | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Input: [1, 2, 3, 4, 3, 2, 1]
Returns: 4