Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Chef has a bucket having a capacity of K liters. It is already filled with X liters of water.
Find the maximum amount of extra water in liters that Chef can fill in the bucket without overflowing.
For each test case, output in a single line, the amount of extra water in liters that Chef can fill in the bucket without overflowing.
Input: 2
5 4
15 6
Output: 1
9
Test Case 1: The capacity of the bucket is 5 liters but it is already filled with 4 liters of water. Adding 1 more liter of water to the bucket fills it to (4+1)=5 liters. If we try to fill more water, it will overflow.
Test Case 2: The capacity of the bucket is 15 liters but it is already filled with 66 liters of water. Adding 9 more liters of water to the bucket fills it to (6+9)=15 liters. If we try to fill more water, it will overflow.
#include <iostream>
using namespace std;
int main() {
int t,k,x;
cin>>t;
while(t--){
cin>>k>>x;
cout<<k-x<<endl;
}
return 0;
}
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner in=new Scanner(System.in);
int n=in.nextInt();
for(int i=0;i<n;i++){
int a=in.nextInt();
int b=in.nextInt();
if(a>=b){
System.out.println(a-b);
}
else {
System.out.println(b-a);
}
}
}
}
t = int(input())
for i in range(t):
k,x = list(map(int,input().split()))
print(k-x)
In our experience, we suggest you solve this Fill the Bucket CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.
If you are stuck anywhere between any coding problem, just visit Queslers to get the Fill the Bucket CodeChef Solution
I hope this Fill the Bucket CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.
This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.
Keep Learning!
More Coding Solutions >>