Your code fails for sequence having multiple duplicates. Also, you can’t just add the min(left,right) directly to your ans. I suggest you to read the example I’ve given in the editorial above
In [1,2,2,3,3] -> [1,2,2,3] (with 3 of index 3) and [1,2,2,3] (with 3 of index 4), both are good subsequence
Its late, but thanks!