Cpp Single liner


#1

This is boilerplate to complete 20 chars :frowning:
return ((C+A-1)%B);


#2

Is it truly pass all the test case?


#3

Yes, it passes all the test cases.

In Java,

public class Solution {
    public int solve(int A, int B, int C) {
        return (C + (A -1)) % B;
    }
}

#4

This is not correct (even though it is passing all the test cases, as you say).
Try running this with A = 4, B = 5 and C = 2.
Output with this solution : 0
Expected output: 5


#5
return ((A%B)+(C%B)-1)%B;

#6

I think it’s wrong
answer should be (A+C-2)%B+1
subtract 1 becuase 1st position where it is delivered is C and another 1 to make it 0 indexed and then add 1 in the end