You are viewing a single comment's thread. Return to all comments →
Hey McLaughin, can you please tell whats wrong with this one!
` static int cookies(int k, int[] a) { /* * Write your code here. */ int c=0; ArrayList al = new ArrayList(); for(int i : a){ al.add(i); }
while(true){ Collections.sort(al); if(al.get(0) < k){ al = func(al); c++; } else break; } if(al.size() == 0) return -1; return c; } static ArrayList<Integer> func(ArrayList<Integer> ar){ int temp = ar.get(0) + (ar.get(1)*2); ar.set(1,temp); ar.remove(0); return ar; }```
Seems like cookies are disabled on this browser, please enable them to open this website
Jesse and Cookies
You are viewing a single comment's thread. Return to all comments →
Hey McLaughin, can you please tell whats wrong with this one!
` static int cookies(int k, int[] a) { /* * Write your code here. */ int c=0; ArrayList al = new ArrayList(); for(int i : a){ al.add(i); }