Sort by

recency

|

1787 Discussions

|

  • + 0 comments

    Here is my c++ solution you can find the video here : https://youtu.be/MHFroRIBGQc

    void bonAppetit(vector<int> bill, int k, int b) {
        int s = accumulate(bill.begin(), bill.end(), -1 * bill[k]);
        int c = s / 2;
        if(c == b) cout << "Bon Appetit";
        else cout << b - c;
    }
    
  • + 0 comments

    Splitting bills can be tricky, like when you're with friends at a restaurant. It's like if Top Roofing Contractors in Hartsville charged everyone equally for a job, even if some didn't need the full service.

  • + 0 comments

    Here is my c++ solution you can find the video here https://bitlifeapk.org

  • + 1 comment

    Java 8

        bill.remove(k);
        int actual = bill.stream().mapToInt(Integer::intValue).sum() / 2;
        if(actual == b){
            System.out.println("Bon Appetit");
        } else {
            int refund = b - actual;
            System.out.println(refund);
        }
    
  • + 0 comments
    C# solution

    C# * public static void bonAppetit(List bill, int NoEat, int charged) * { * //remove item that she doesn't it from bill list * bill.RemoveAt(NoEat); * //sum the bill and minus the amount charged * int refund = (charged - (bill.Sum()/2)); * //do simple if else then in console.write IF balance is 0, write Bon Appetit else write refund * Console.Write(refund == 0 ? "Bon Appetit": refund); * }