-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDistribute in Circle!.java
More file actions
81 lines (50 loc) · 1.23 KB
/
Distribute in Circle!.java
File metadata and controls
81 lines (50 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
Problem Description
A items are to be delivered in a circle of size B.
Find the position where the Ath item will be delivered if we start from a given position C.
NOTE: Items are distributed at adjacent positions starting from C.
Problem Constraints
1 <= A, B, C <= 108
Input Format
First argument is an integer A.
Second argument is an integer B.
Third argument is an integer C.
Output Format
Return an integer denoting the position where the Ath item will be delivered if we start from a given position C.
Example Input
Input 1:
A = 2
B = 5
C = 1
Input 2:
A = 8
B = 5
C = 2
Example Output
Output 1:
2
Output 2:
4
Example Explanation
Explanation 1:
The first item will be given to 1st position. Second (or last) item will be delivered to 2nd position
Explanation 2:
The last item will be delivered to 4th position */
public class Solution {
public int solve(int a, int b, int c) {
// int ans = 0;
// if(A<=B){
// ans += A;
// }else if(A>B){
// ans += A-B;
// }
// int rem = C - 1;
// ans += rem;
// return ans;
// int ans=0;
// if(a>b){
// a%=b;
// }
return (c+a-1)%b;
}
}