package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/final-prices-with-a-special-discount-in-a-shop/
 */
public class Problem1475 {
    public int[] finalPrices(int[] prices) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem1475 prob = new Problem1475();
        System.out.println(Arrays.toString(prob.finalPrices(new int[]{8,4,6,2,3}))); // [4,2,4,2,3]
        System.out.println(Arrays.toString(prob.finalPrices(new int[]{1,2,3,4,5}))); // [1,2,3,4,5]
        System.out.println(Arrays.toString(prob.finalPrices(new int[]{10,1,1,6}))); // [9,0,1,6]
        System.out.println(Arrays.toString(prob.finalPrices(new int[]{1,2,3,4,1}))); // [0,1,2,3,1]
    }
}

@@ -211,531 +211,410 @@
     
-// TODO%0A        return null
+int%5B%5D answer = new int%5Bprices.length%5D
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem1475 prob = new Problem1475();%0A        System.out.println(Arrays.toString(prob.finalPrices(new int%5B%5D%7B8,4,6,2,3%7D))); // %5B4,2,4,2,3%5D%0A        System.out.println(Arrays.toString(prob.finalPrices(new int%5B%5D%7B1,2,3,4,5%7D))); // %5B1,2,3,4,5%5D%0A        System.out.println(Arrays.toString(prob.finalPrices(new int%5B%5D%7B10,1,1,6%7D))); // %5B9,0,1,6%5D%0A        System.out.println(Arrays.toString(prob.finalPrices(new int%5B%5D%7B1,2,3,4,1%7D))); // %5B0,1,2,3,1%5D
+for (int i = 0; i %3C prices.length; i++) %7B%0A            int discount = 0;%0A            for (int j = i + 1; j %3C prices.length; j++) %7B%0A                if (prices%5Bj%5D %3C= prices%5Bi%5D) %7B%0A                    discount = prices%5Bj%5D;%0A                    break;%0A                %7D%0A            %7D%0A            answer%5Bi%5D = prices%5Bi%5D - discount;%0A        %7D%0A        return answer;
 %0A   

Solve problem 1475