I think you need to prove the following thing is correct for this algorithm correctness.
how to make sure the max value nums[j] always is stored in s3 when you check nums[i], where nums[j] < nums[k], j,k both > i.
If you always store this max value in s3 when you check every nums[i], you can find out the solution.
I almost can prove it but can't strictly prove it.
Anyway, I think this algorithm is hard.
Appreciate someone can prove this.