# --------------------------------------------- # Problem 1 # Find the starting position of the longest # increasing suffix from the back. # # A suffix means the sequence starting from # some position to the end. # # Input # 4 # 1 2 5 3 # # Output # 4 # # Explanation # From the back: # 5 < 3 is false, # so the increasing part starts at position 4. # --------------------------------------------- # --------------------------------------------- # Problem 2 # Find the length of the increasing suffix # from the back. # # Input # 4 # 7 1 2 3 # # Output # 3 # # Explanation # From the back: # 2 < 3 ✔ # 1 < 2 ✔ # 7 < 1 ✘ # # Increasing suffix: # 1 2 3 # # Length: # 3 # --------------------------------------------- # --------------------------------------------- # Problem 3 # You can move only the first number. # # In one operation: # - Remove the first number # - Insert it into any position # # Find the minimum number of operations # needed to make the sequence increasing. # # Input # 3 # 1 3 2 # # Output # 2 # # Explanation # From the back: # 3 < 2 ✘ # # The sorted suffix is: # 2 # # Numbers that must be moved: # 1, 3 # # Total operations: # 2 # ---------------------------------------------
To embed this project on your website, copy the following code and paste it into your website's HTML: