solution link: https://ide.codingblocks.com/s/292795
one test case is not passing
your code fails for input
1 2 3 4 5 6 -1
6
your output 2
correct output 1
Modified Code
if you have more doubts regarding this feel free to ask
i hope this helps
if yes hit a like and don’t forgot to mark doubt as resolved 