@@ -0,0 +1,851 @@
+// https://community.topcoder.com/stat?c=problem_statement&pm=12508%0A%0A/*%0A * Optimization ideas:%0A * - use a boolean array to check whether there are any drops left to absorb from intensity%5B%5D%0A * - minimize iterations in inner loop (obviously it doesn't need to loop all the way to N-1)%0A */%0A%0Apublic class TheExperimentDiv2 %7B%0A%09public static int%5B%5D determineHumidity(int%5B%5D intensity, int L, int%5B%5D leftEnd) %7B%0A%09%09int N = intensity.length;%0A%09%09int M = leftEnd.length;%0A%09%09%0A%09%09int%5B%5D dropsAbsorbed = new int%5BM%5D;%0A%09%09%0A%09%09for (int i = 0; i %3C M; ++i) %7B%0A%09%09%09int spongeStartIndex = leftEnd%5Bi%5D;%0A%09%09%09int spongeEndIndex = leftEnd%5Bi%5D + L - 1;%0A%09%09%09%0A%09%09%09for (int j = 0; j %3C N; ++j) %7B%0A%09%09%09%09if (j %3E= spongeStartIndex && j %3C= spongeEndIndex) %7B%0A%09%09%09%09%09if (intensity%5Bj%5D %3E 0) %7B%0A%09%09%09%09%09%09dropsAbsorbed%5Bi%5D += intensity%5Bj%5D;%0A%09%09%09%09%09%09intensity%5Bj%5D = 0;%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09return dropsAbsorbed;%0A%09%7D%0A%7D%0A

Create TheExperimentDiv2.java