Hi I have a data structures programming project involving creating my own array based list and then efficiently storing String read from a file but in reverse.So that arr[0] = the last line of the fileInitially I just thought to have two for loops:First to store the data by its order in my listSecond to create a new list and add elements in reverse orderThen I thought about just creating an array based list that stores data in reverse, so that the first line of the file is stored at arr[arr.length-1] and so on. This I believe is saving me a for loopI know in the end both are O(n), but is this what my professor means when he says as efficient as possible?Are there any other ways I could reverse my list?Thanks.
Storing data in reverse order in an array based list efficiently
java;data structures