package leetcode;

/**
 * https://leetcode.com/problems/apply-discount-every-n-orders/
 */
public class Problem1357 {
    private static class Cashier {
        public Cashier(int n, int discount, int[] products, int[] prices) {
            // TODO
        }

        public double getBill(int[] product, int[] amount) {
            // TODO
            return 0;
        }
    }

    public static void main(String[] args) {
        Cashier cashier = new Cashier(
            3, 50, new int[]{1, 2, 3, 4, 5, 6, 7}, new int[]{100, 200, 300, 400, 300, 200, 100});
        System.out.println(cashier.getBill(new int[]{1, 2}, new int[]{1, 2})); // 500
        System.out.println(cashier.getBill(new int[]{3, 7}, new int[]{10, 10})); // 4000
        System.out.println(cashier.getBill(new int[]{1, 2, 3, 4, 5, 6, 7}, new int[]{1, 1, 1, 1, 1, 1, 1})); // 800
        System.out.println(cashier.getBill(new int[]{4}, new int[]{10})); // 4000
        System.out.println(cashier.getBill(new int[]{7, 3}, new int[]{10, 10})); // 4000
        System.out.println(cashier.getBill(new int[]{7, 5, 3, 1, 6, 4, 2}, new int[]{10, 10, 10, 9, 9, 9, 7})); // 7350
        System.out.println(cashier.getBill(new int[]{2, 3, 5}, new int[]{5, 3, 2})); // 2500

    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashMap;%0Aimport java.util.Map;%0A%0A
 /**%0A * h
@@ -208,207 +208,895 @@
    p
-ublic Cashier(int n, int discount, int%5B%5D products, int%5B%5D prices) %7B%0A            // TODO%0A        %7D%0A%0A        public double getBill(int%5B%5D product, int%5B%5D amount) %7B%0A            // TODO%0A            return 0
+rivate final int n;%0A        private final int discount;%0A        private Map%3C/* product= */ Integer, /* price= */ Integer%3E prices = new HashMap%3C%3E();%0A        private int count = 0;%0A%0A        public Cashier(int n, int discount, int%5B%5D products, int%5B%5D prices) %7B%0A            this.n = n;%0A            this.discount = discount;%0A            for (int i = 0; i %3C products.length; i++) %7B%0A                this.prices.put(products%5Bi%5D, prices%5Bi%5D);%0A            %7D%0A        %7D%0A%0A        public double getBill(int%5B%5D product, int%5B%5D amount) %7B%0A            count++;%0A            double total = 0;%0A            for (int i = 0; i %3C product.length; i++) %7B%0A                double price = prices.get(product%5Bi%5D);%0A                if (count %25 3 == 0) %7B%0A                    price = (prices.get(product%5Bi%5D) * discount) / 100;%0A                %7D%0A                total += price * amount%5Bi%5D;%0A            %7D%0A            return total
 ;%0A  

Update problem 1357