Last active
October 6, 2018 02:40
-
-
Save cloudbank/1d4bfd4c17479161ad44333aada00eb4 to your computer and use it in GitHub Desktop.
determine the salary cap given a target and list of salaries (unsorted)
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
public int salaryCap(int[] salaries, int target) { | |
int a = target / salaries.length; | |
int sum = 0, count=0; | |
for (int s: salaries) { | |
if (s <= a) { | |
sum += s; | |
} else { | |
count++; | |
} | |
} | |
return ((target - sum) / ((salaries.length) - (count))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment