Answers for "hackerrank golang bon appetit"

0

hackerrank golang bon appetit

func bonAppetit(bill []int32, k int32, b int32) {
     var anna, notPaid int32
     notPaid = bill[k]
     
     for i := 0; int32(i) < int32(len(bill)); i++ {
         if bill[i] < notPaid {
           anna += bill[i]
         } 
     } 
    
     divide := anna - bill[k] / 2
     subtract := b - int32(divide)
     
     var result interface{}
     
     if subtract > 0 {
       result = subtract
     } else {
       result = "Bon Appetit"
     }
     
    fmt.Println(result)
}
Posted by: Guest on October-29-2021

Browse Popular Code Answers by Language