We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static void bonAppetit(List<Integer> bill, int k, int b) {
// Write your code here
int billAnna = 0;
int billSum = 0;
for (int i : bill) {
billSum += i;
}
int billSplit = billSum / 2;
if (billSplit == b) {
for (int i = 0; i < bill.size(); i++) {
if (i == k) {
continue;
}
billAnna += bill.get(i);
}
System.out.println((b - (billAnna / 2)));
} else {
System.out.println("Bon Appetit");
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Bill Division
You are viewing a single comment's thread. Return to all comments →
java(8)