class GrowingArray { private int[] data; public GrowingArray() { data = new int[8]; // default size } private int getNextPowerOfTwo(int num) { int result = 2; while (result < num) result *= 2; return result; } private void resize(int size) { int tmp[] = new int[getNextPowerOfTwo(size)]; // create new object for (int i=0; i= data.length) return 0; // resize if too small, size is index+1 due to 0 indexing of arrays return data[ind]; } public void set(int ind, int val) { if (ind >= data.length) resize(ind+1); // resize if too small, size is index+1 due to 0 indexing of arrays data[ind] = val; } public int size() { return data.length; } } //--------------------------------------------------------------------------------- //Unfortunately it is a restriction of the judge that we always have to have a public class Main in our file //The code below is only used to validate your code with the judge - feel free to browse - but its not required for the exercise //------------------------------------------------------------------------------------------------------------------------ class Main{ public static void main(String[] args) { java.util.Scanner scanner = new java.util.Scanner(System.in); GrowingArray testit = new GrowingArray(); int index = 0; while(scanner.hasNextInt()){ testit.set(index, scanner.nextInt()); index++; } GrowingArray testit2 = new GrowingArray(); for (int i = 0; i< testit.size(); i ++) { int index2 = testit.get(i); testit2.set(index2, i); } for (int i = 0; i < testit2.size(); i ++ ) System.out.println(testit2.get(i)); scanner.close(); } } /* for sample input: 801 803 796 934 956 177 94 354 920 379 242 32 157 772 196 459 743 187 941 378 175 497 57 70 66 986 75 864 391 426 150 440 948 743 240 431 723 75 532 19 411 700 792 230 141 716 1021 754 971 631 635 260 131 556 176 604 476 494 603 704 324 565 281 330 310 42 966 703 78 786 428 707 969 75 595 719 363 25 696 535 930 639 841 287 423 199 401 72 57 183 415 323 86 79 35 259 878 143 387 174 end you should get the following output: 127 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 39 0 0 0 0 0 77 0 0 0 0 0 0 11 0 0 94 0 0 0 0 0 0 65 0 0 0 0 0 0 0 0 0 0 0 0 0 0 88 0 0 0 0 0 0 0 0 24 0 0 0 23 0 87 0 0 73 0 0 68 93 0 0 0 0 0 0 92 0 0 0 0 0 0 0 6 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 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