Given a string sentence, write a program that reverses it.
Sigiloso
I wrote this in Java. 1) Define a Scanner that iterates through the string input backwards and a Stack. 2) Push each word followed by a space character onto the Stack. Replace the space with a period for the first word. This is an O(n) time operation. 3) Pop each word from the Stack and you'll get the reversed sentence in O(n) time. Overall time complexity: O(n) Overall space complexity: O(n)