package leetcode;

/**
 * https://leetcode.com/problems/pour-water/
 */
public class Problem756 {
    public int[] pourWater(int[] heights, int V, int K) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem756 prob = new Problem756();
        System.out.println(prob.pourWater(new int[]{2, 1, 1, 2, 1, 2, 2}, 4, 3)); // [2,2,2,3,2,2,2]
        System.out.println(prob.pourWater(new int[]{1, 2, 3, 4}, 2, 2)); // [2,3,3,4]
        System.out.println(prob.pourWater(new int[]{3, 1, 3}, 5, 1)); // [4,4,4]
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -187,35 +187,705 @@
     
-// TODO%0A        return null
+outer:%0A        for (int i = 0; i %3C V; i++) %7B%0A            // left%0A            for (int j = K; j %3E= 0; j--) %7B%0A                int left = (j - 1 %3C 0) ? Integer.MIN_VALUE : heights%5Bj - 1%5D;%0A                if (heights%5Bj%5D %3C left) %7B%0A                    heights%5Bj%5D++;%0A                    continue outer;%0A                %7D%0A            %7D%0A            // right%0A            for (int j = K; j %3C heights.length; j++) %7B%0A                int right = (j + 1 %3C heights.length) ? Integer.MIN_VALUE : heights%5Bj + 1%5D;%0A                if (heights%5Bj%5D %3C right) %7B%0A                    heights%5Bj%5D++;%0A                    continue outer;%0A                %7D%0A            %7D%0A            heights%5BK%5D++;%0A        %7D%0A        return heights
 ;%0A  
@@ -997,32 +997,48 @@
 tem.out.println(
+Arrays.toString(
 prob.pourWater(n
@@ -1049,28 +1049,154 @@
 nt%5B%5D
-%7B
+ %7B 
 2, 1, 
-1, 2, 1, 2, 2
+2, 2, 1, 2, 2 %7D, 1, 3))); // %5B2,2,2,2,1,2,2%5D%0A//        System.out.println(Arrays.toString(prob.pourWater(new int%5B%5D %7B 2, 1, 1, 2, 1, 2, 2 
 %7D, 4
@@ -1200,16 +1200,17 @@
 , 4, 3))
+)
 ; // %5B2,
@@ -1222,16 +1222,18 @@
 ,2,2,2%5D%0A
+//
         
@@ -1243,32 +1243,48 @@
 tem.out.println(
+Arrays.toString(
 prob.pourWater(n
@@ -1291,17 +1291,19 @@
 ew int%5B%5D
-%7B
+ %7B 
 1, 2, 3,
@@ -1304,16 +1304,17 @@
  2, 3, 4
+ 
 %7D, 2, 2)
@@ -1314,16 +1314,17 @@
 , 2, 2))
+)
 ; // %5B2,
@@ -1326,24 +1326,26 @@
 / %5B2,3,3,4%5D%0A
+//
         Syst
@@ -1359,16 +1359,32 @@
 println(
+Arrays.toString(
 prob.pou
@@ -1403,16 +1403,19 @@
 nt%5B%5D
-%7B
+ %7B 
 3, 1, 3
+ 
 %7D, 5
@@ -1419,16 +1419,17 @@
 , 5, 1))
+)
 ; // %5B4,

Update problem 756