Created
September 8, 2023 12:04
-
-
Save rezaramadhanirianto/c76c09d27175cd2b6d32802df6b9bc4e 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
| long sum = 0, max = Integer.MIN_VALUE, min = Integer.MAX_VALUE; | |
| for(int num: nums) sum += num; | |
| for(int num: nums){ | |
| max = Math.max(max, sum - num); | |
| min = Math.min(min, sum - num); | |
| } | |
| // return max & min | |
| return new int[]{max, min}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment