Company: Autodesk_30sep
Difficulty: medium
Smallest String After Reversals Problem Description Given a string word , you can reverse the order of some characters from the beginning or from the end of word to get new strings. Reversing the first k characters of a string [w_0, w_1, ..., w_{k-1}, w_k, ..., w_{N-1}] produces [w_{k-1}, ..., w_1, w_0, w_k, ..., w_{N-1}] . Reversing the last k characters of a string [w_0, ..., w_{N-k-1}, w_{N-k}, ..., w_{N-1}] produces [w_0, ..., w_{N-k-1}, w_{N-1}, ..., w_{N-k}] . Your task is to iterate over all possible new strings that can be formed this way, and return the alphabetically smallest one. Note: You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(word.length³) will fit within the execution time limit. Examples Example 1: Input: word = "dbaca" Output: "abdca" Explanation: Let's consider all possible reverse operations for word = "dbaca" : Reversing the first 1 character results in the following: "dbaca" Reversing the first 2 c