Find the position of M-th item
Basic Accuracy: 28.51% Submissions: 389 Points: 1

M items are to be delivered in a circle of size N. Find the position where the M-th item will be delivered if we start from a given position K. Note that items are distributed at adjacent positions starting from K.


Example 1:

N = 5, M = 2, K = 1
If we start from 1st position, the
2nd item will land at the 2nd position.

Example 2:

N = 5, M = 8, K = 2
If we start from 2nd position, the
8th item will land at the 4th position.


Your Task:
You don't need to read input or print anything. Your task is to complete the function findPosition() which takes 3 Integers N,M and K as input and returns the answer.


Expected Time Complexity: O(1)
Expected Auxiliary Space: O(1)


1 <= N,M,K <= 105

We are replacing the old Disqus forum with the new Discussions section given below.
Click here to view old Disqus comments.

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.

Find the position of M-th item

Output Window