implemented P5FindMinSubsequence in O(n)