• + 0 comments

    python code with O(n) time and O(1) time:

    def bonAppetit(bill, k, b):
        total = sum(bill)
        anas_cost = total - bill[k]
        even_split = anas_cost / 2
        
        if even_split == b:
            print("Bon Appetit")
        else:
            print(math.floor(b - even_split))