@@ -0,0 +1,1043 @@
+// https://community.topcoder.com/stat?c=problem_statement&pm=12112%0A%0Apublic class LittleElephantAndBooks %7B%0A%09public static int getNumber(int%5B%5D pages, int number) %7B%0A%09%09int pageCount = 0;%0A%09%09%0A%09%09// Sort via bubble sort%0A%09%09int j = 0;%0A%09%09boolean stillSwapping = true;%0A%09%09while (stillSwapping) %7B%0A%09%09%09stillSwapping = false;%0A%09%09%09j++;%0A%09%09%09for (int i = 0; i %3C pages.length - j; ++i) %7B%0A%09%09%09%09if (pages%5Bi%5D %3E pages%5Bi+1%5D) %7B%0A%09%09%09%09%09int temp = pages%5Bi%5D;%0A%09%09%09%09%09pages%5Bi%5D = pages%5Bi+1%5D;%0A%09%09%09%09%09pages%5Bi+1%5D = temp;%0A%09%09%09%09%09stillSwapping = true;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09/*%0A%09%09 * The lazy elephants will always choose the first 'number' books.%0A%09%09 * Therefore Little Elephant needs to read the first 'number-1' books. %0A%09%09 * After that he should skip the book with the number 'number-1' (in order to not become a lazy elephant)%0A%09%09 * and instead read the book with the number 'number' to be a good little unique elephant.%0A%09%09 */%0A%09%09%0A%09%09// Get second smallest subset sum%0A%09%09for (int i = 0; i %3C number-1; ++i) %7B%0A%09%09%09pageCount += pages%5Bi%5D;%0A%09%09%7D%0A%09%09pageCount += pages%5Bnumber%5D;%0A%09%09%0A%09%09return pageCount;%0A%09%7D%0A%7D%0A

Create LittleElephantAndBooks.java