Write a program to reverse a linked list, and discuss the time and space complexity of your approach.