Your question is Reverse Words in a Sentence. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
NCR Corporation surfaces may need to reorder words in a sentence before displaying or processing text. Given a sentence, return its words in reverse order while normalizing whitespace to single spaces.
Implement reverse_words(sentence, method) with three supported approaches:
iterative: Use an iterative algorithm.recursive: Use a recursion that processes one word position at a time.fibonacci: Use branching recursion similar in structure to Fibonacci, where the helper recursively processes two subranges and combines them in reverse order. This approach should branch, but it must not repeatedly recompute the same subproblem.sentence, a string containing zero or more words separated by arbitrary whitespace, and method, one of the three method names above."".def reverse_words(sentence, method):