Doctors Clinic | Practice | GeeksforGeeks

Given two positive integers N and X, where N is the number of total patients and X is the time duration(in minutes) after which a new patient arrives. Also, doctor will give only 10 minutes to each patient. The task is to calculate the time (in minutes) the last patient needs to wait.
Example 1:
Input: N = 4, X = 5
Output: 15
Explaination: The arrival time of the 
patients are 0, 5, 10 and 15 respectively. 
The times when the first three patients 
are checked are respectively 10, 20, 30. 
So the Waiting time is 30 - 15 = 15.
Example 2:
Input: N = 3, X = 10
Output: 0
Explaination: The incoming time of the 
patients are 0, 10 and 20 and the firts 
two patients are finished checking at 10, 
20. So the last patient does not need to 
wait.
Your Task:
You do not need to read input or print anything. Your task is to complete the function waitingTime() which takes N and X as input parameters and returns the waiting time of the last patient.
Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)
Constraints:
1 ≤ N ≤ 100
1 ≤ X ≤ 30
0
prashantdhruw2 months ago
class Solution{   static int waitingTime(int N, int X){       if(X>10){           return 0;       }else{   return ((N - 1) * (10 - X));         }   }}
0
prashantdhruw
This comment was deleted.
-1
shubham4393 months ago
int sum = 0;
        int wait = 0;
        int ans = 0;
        if(X>=10 && N>1){
            return 0;
        }
        if(N==0)
        return 0;
        if(X<10){
            for(int i = 1;i<N;i++){
                wait = wait+10;
                sum = sum+X;
                
            }
            ans = wait-sum;
            
        }
        return ans;
+1
badgujarsachin839 months ago
class Solution{
public:
    int waitingTime(int N, int X){
        // code here
        if(X>=10){
            return 0;
        }
        int patient=(N-1)*X;
        int doctor=(N-1)*10;
        int wait=doctor-patient;
        return wait;
    }
};
0
badgujarsachin839 months ago
-1
nagesh371270110 months ago
Given two positive integers N and X, where N is the number of total patients and X is the time duration(in minutes) after which a new patient arrives. Also, doctor will give only 10 minutes to each patient. The task is to calculate the time (in minutes) the last patient needs to wait.
-1
kumarbabalu92310 months ago
Babalu Kumar
0
Amar Prakash1 year agoint waitingTime(int N, int X){        if( X > 10)        {            return 0;        }        return ((N-1)*10 - (N-1)*X);        // code here    }Reply Open ExternallyShow 0 RepliesLoading...
Amar Prakash
int waitingTime(int N, int X){
        if( X > 10)        {            return 0;        }
        return ((N-1)*10 - (N-1)*X);        // code here    }
-1
Jaspreet Singh2 years agoclass Solution{    static int waitingTime(int N, int X){        // code hereint x=10;if(X>10)return 0;elsereturn(x*(N-1)-X*(N-1));    }}Reply Open ExternallyShow 0 RepliesLoading...
Jaspreet Singh
class Solution{    static int waitingTime(int N, int X){        // code hereint x=10;if(X>10)return 0;elsereturn(x*(N-1)-X*(N-1));    }}
0
Rohit kumar2 years ago#include <iostream>using namespace std;int main() {//codeint t,X,N;cin>>t;while(t--)             {    cin>>N>>X;                   cout<<((10-X)*(N-1))<<endl; }="" return="" 0;="" }="">Reply Open ExternallyShow 0 RepliesLoading...
Rohit kumar
#include <iostream>using namespace std;
int main() {//codeint t,X,N;cin>>t;while(t--)             {    cin>>N>>X;                   cout<<((10-X)*(N-1))<<endl; }="" return="" 0;="" }="">
We strongly recommend solving this problem on your own before viewing its editorial. Do you still
                    want to view the editorial?
 Login to access your submissions. 

Problem


Contest

Reset the IDE using the second button on the top right corner.
Avoid using static/global variables in your code as your code is tested 
                                    against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases does not guarantee the correctness of code.
                                    On submission, your code is tested against multiple test cases consisting of all
                                        possible corner cases and stress constraints.
You can access the hints to get an idea about what is expected of you as well as
                                        the final solution code.
You can view the solutions submitted by other users from the submission tab.
Make sure you are not using ad-blockers.
Disable browser extensions.
We recommend using latest version of your browser for best experience.
Avoid using static/global variables in coding problems as your code is tested 
                                against multiple test cases and these tend to retain their previous values.
Passing the Sample/Custom Test cases in coding problems does not guarantee the 
                                correctness of code. On submission, your code is tested against multiple test cases
                                    consisting of all possible corner cases and stress constraints.