There is some problem in the while loop in my code at line 82 which is to be executed when the front of both the queues are not same. Please help.
Importance of time problem
Hey @rahul.gupta03111999
Problem is with your rotatebyone function
void leftRotatebyOne()
{
ll temp = front();
int i;
for ( i = 0; i < ms - 1; i++) //this should be ms instead of cs
arr[i] = arr[i + 1];
arr[i] = temp;
}
You can implement it like this ,its more optimized this way
void leftRotatebyOne()
{
ll temp = front();
f=(f+1)%ms;
r=(r+1)%ms;
arr[r]=temp;
}
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.