You are viewing a single comment's thread. Return to all comments →
Just completed this problem and this solution is eerily similar to mine:
static int luckBalance(int k, int[][] contests) { List<Integer> important = new ArrayList<Integer>(); int totalLuck = 0; for(int i = 0; i < contests.length; i++){ if(contests[i][1] == 1){ important.add(contests[i][0]); } totalLuck += contests[i][0]; } int canWin = important.size() - k, score = 0; Collections.sort(important); for(int i = 0; i < canWin; i++){ score += 2 * important.get(i); } return totalLuck - score; }
Great minds think alike? haha
Luck Balance
You are viewing a single comment's thread. Return to all comments →
Just completed this problem and this solution is eerily similar to mine:
Great minds think alike? haha