[CC150v5] 17.6 Order an Array by Sorting Middle - Shuatiblog.com
Given an array of integers, write a method to find indices m and n such that if you sorted elements m through n, the entire array would be sorted. Minimize n-m (that is, find the smallest such sequence).
Solution
Referring to this guy:
找到heading的最长递增序列.
找到tailing的最长的递增序列.
After that:
用中间部分的min去shrink左边.
用中间部分的max去shrink右边.
Read full article from [CC150v5] 17.6 Order an Array by Sorting Middle - Shuatiblog.com
No comments:
Post a Comment