• + 0 comments

    Solution in Java

    public static void bonAppetit(List<Integer> bill, int k, int b) {
            int share = 0;
            for(int i = 0; i < bill.size(); i++){
                if(i != k){
                    share += bill.get(i);
                }
            }
            if((share / 2) == b){
                System.out.println("Bon Appetit");
            }
            else{
                System.out.println(b - share / 2);
            }
        }