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 = the last line of the file
Initially I just thought to have two for loops:
First to store the data by its order in my list
Second to create a new list and add elements in reverse order
Then 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 loop
I 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?