Algorithm · Amazon · Medium
You are given an integer array arr containing n distinct integers. You can perform exactly two kinds of moves, each costing one step: Rotate: Take the first element and move it to the end of the array. For instance, [a, b, c, d] becomes [b, c, d, a]. Flip: Reverse the entire array. For instance, [a, b, c, d] becomes [d, c, b, a]. You may use these moves as many times as you wish, in any sequence. Your task is to compute the minimum number of steps required to make arr sorted…
Checking your access…