Suppose a Java method receives a List and reverses the order of the items it contains by removing each item from the front of the list, adding each item to a Stack, and then removing the items from the stack and inserting each item to the end of the list. What is the expected Big-O running time if an ArrayList, a LinkedList is passed.ArrayList is O(N^2) because removing each item requires the preceding items to be shifted up, which takes O(N) time, and there are N iterations. LinkedList is O(N) since moving pointers requires O(1) time, with N iterations.What is the Big-O running time of the following code fragment? Assume lst1 has N items, and lst2 is initially empty.public static void add( List<Integer> lst1, List<Integer> lst2){for ( Integer x : lst1 )lst2.add(0, x);  // add to front}ArrayList is O(N^2) because adding to the front requires moving the other elements down, which takes O(N) time, and there are N iterations. LinkedList is O(N) since adding to the front only requires O(1) time, with N iterations.Ideally I'd like to know hints to arrive to a correct answer by my own devices if there are any incorrect answers.
Complexity of ArrayList and LinkedList
java