I need help with the 2nd TODO comment and the other comments

I need help with the 2nd //TODO comment and the other comments I\'ll post at the end. I keep exceeding my memory when I write something for it

public static ArrayList<Integer> doArrayListRemoveFromEnd(int numItems) {
       System.out.print(\"doArrayListRemoveFromEnd: \");
       ArrayList<Integer> list = new ArrayList<>();

       // TODO Write code that adds integers 0 through (numitems - 1)
       // to list, inside a loop.

       for(int i=0; i<=numItems-1; i++){
       list.add(i);
       }
      
       long startTime = getTimestamp();

       // TODO Write code that removes the last element from list,
       // repeatedly until the list is empty.

       int last = list.size();

      
       long endTime = getTimestamp();
       long totalTime = endTime - startTime;
       System.out.println(totalTime);
      
       return list;
   }

// TODO Write code that removes the greatest element from set,
       // repeatedly until the set is empty.

// TODO Write code that removes the first element from list,
       // repeatedly until the list is empty.

// TODO Write code that gets the element at the last index from list.

// TODO Write code that checks if integer (numItems - 1)
       // is a member of set.

Solution

public static ArrayList<Integer> doArrayListRemoveFromEnd(int numItems) {
System.out.print(\"doArrayListRemoveFromEnd: \");
ArrayList<Integer> list = new ArrayList<>();
// TODO Write code that adds integers 0 through (numitems - 1)
// to list, inside a loop.
for(int i=0; i<=numItems-1; i++){
list.add(i);
}
  
long startTime = getTimestamp();
// TODO Write code that removes the last element from list,
// repeatedly until the list is empty.
  
for(int i=0; i<=numItems-1; i++){
   int last=list.size()-1;
list.remove(last);
}
long endTime = getTimestamp();
long totalTime = endTime - startTime;
System.out.println(totalTime);
  
return list;
}
// TODO Write code that removes the greatest element from set,
// repeatedly until the set is empty.
for(int i=0; i<=numItems-1; i++){
int pos = 0;
int max=list.get(0);
for (int i = 1; i < list.size(); i++) {
if(list.get(i) > max) {
max=list.get(i);
pos=i;
}
}

list.remove(pos);
}
// TODO Write code that removes the first element from list,
// repeatedly until the list is empty.
for(int i=0; i<=numItems-1; i++){
list.remove();
}
// TODO Write code that gets the element at the last index from list.
int element=list.get(list.size()-1);
// TODO Write code that checks if integer (numItems - 1)
// is a member of set.
for(int i=0; i<=numItems-1; i++){
    {
        if(item==list.get(i))
        {
            return true;
           }
       }
       return false;

I need help with the 2nd //TODO comment and the other comments I\'ll post at the end. I keep exceeding my memory when I write something for it public static Arr
I need help with the 2nd //TODO comment and the other comments I\'ll post at the end. I keep exceeding my memory when I write something for it public static Arr

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site