The algorithm is wrong at 13:24 for [5,3,0,3,1,-1,2]. It fails the condition where i < j < k. When you update variable named as first in code using if condition with -1(from nums[5] in list which is j) , the variable named second holds value 1 (from nums[4] in list which is i). Therefore fails the condition i
We can just use a stack and maintain increasing sequence in it. You explanation also follows the same logic but is difficult to understand in comparison to stack. Let me know if my proposal is incorrect and miss any test cases
The algorithm is wrong at 13:24 for [5,3,0,3,1,-1,2]. It fails the condition where i < j < k.
When you update variable named as first in code using if condition with -1(from nums[5] in list which is j) , the variable named second holds value 1 (from nums[4] in list which is i). Therefore fails the condition i
True
dry-run was exemplary. thank you
Welcome :)
We can just use a stack and maintain increasing sequence in it. You explanation also follows the same logic but is difficult to understand in comparison to stack. Let me know if my proposal is incorrect and miss any test cases
Yes you can solve using stack too :)
love the explanation!
Very good explanation 👏 keep it up
your explanations are super cool
Thanks :)
nice explanation. no others could have explained to me like this. thanks!
Best 👌