Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int poisonousPlants(int[] p) {
- int i=1;//counter off days
- LinkedList<Integer> alive1 =new LinkedList<>();
- LinkedList<Integer> alive2 =new LinkedList<>();
- LinkedList<Integer>pfull=alive1;
- LinkedList<Integer>pEmpty=alive2;
- for (int plant: p) { pfull.push(plant); }//now the element exist at list
- int presize=0;
- for ( i=0; presize!=pfull.size(); i++) {
- pEmpty.push(pfull.get(0));//the first element don't have left so it remains always
- for (int j = 1; j <pfull.size() ; j++) {
- if (pfull.get(j) < pfull.get(j - 1)) {
- pEmpty.push(pfull.get(j));
- }
- }
- System.out.println("hi");
- System.out.println(pfull.size());
- presize=pfull.size();
- LinkedList<Integer> old=pEmpty;
- pfull.clear();
- pEmpty=pfull;
- pfull=old;
- System.out.println("hello");
- }
- System.out.println("ajksj");
- return i;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement