Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public int[] findTwoHighestDistinctValues(int[] array)
- {
- int max = Integer.MIN_VALUE;
- int secondMax = Integer.MIN_VALUE;
- for (int value:array)
- {
- if (value > max)
- {
- secondMax = max;
- max = value;
- }
- else if (value > secondMax && value < max)
- {
- secondMax = value;
- }
- }
- return new int[] { max, secondMax };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement