Created
February 23, 2017 23:50
-
-
Save jraczak/6859af0ccb9eb7dba5a1eafca67fd818 to your computer and use it in GitHub Desktop.
This file contains hidden or 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[] findTheNumbers(int[] a) { | |
int[] theNumbers = new int[2]; | |
Arrays.sort(a); | |
int matchedNumbers = 0; | |
while (matchedNumbers < 2) { | |
for (int i=0; i < a.length; i++) { | |
if (a[i] != a[i+1]) { | |
theNumbers[matchedNumbers] = a[i]; | |
matchedNumbers++; | |
} | |
} | |
} | |
return theNumbers; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment