Skip to content

Commit 46b64fa

Browse files
committed
Added Distribute Money to Maximum Children.java
1 parent f3c457c commit 46b64fa

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution {
2+
public int distMoney(int money, int children) {
3+
money -= children;
4+
if (money < 0) {
5+
return -1;
6+
}
7+
if (money / 7 == children && money % 7 == 0) {
8+
return children;
9+
}
10+
if (money / 7 == children - 1 && money % 7 == 3) {
11+
return children - 2;
12+
}
13+
return Math.min(children - 1, money / 7);
14+
}
15+
}

0 commit comments

Comments
 (0)