@@ -0,0 +1,701 @@
+package java_problems.beginner;%0A%0Aimport java.util.Scanner;%0A%0Apublic class GreedyPuppy %7B%0A%0A%09public static void main(String%5B%5D args) %7B%0A%09%09%0A%09%09Scanner sc = new Scanner(System.in);%0A%09%09int numCases = Integer.parseInt(sc.nextLine());%0A%09%09for (int i = 0; i %3C numCases; i++) %7B%0A%09%09%09int numCoins = sc.nextInt();%0A%09%09%09int maxPeople = sc.nextInt();%0A%09%09%09System.out.println(getMaxRemainder(numCoins, maxPeople));%0A%09%09%7D%0A%09%09sc.close();%0A%09%7D%0A%09%0A%09private static int getMaxRemainder(int coins, int people) %7B%0A%09%09int maxRemainder = Integer.MIN_VALUE;%0A%09%09for (int i = 1; i %3C= people; i++) %7B%0A%09%09%09int currentRemainder = coins %25 i;%0A%09%09%09if (currentRemainder %3E maxRemainder) %7B%0A%09%09%09%09maxRemainder = currentRemainder;%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return maxRemainder;%0A%09%7D%0A%7D

Add GreedyPuppy