Codeforces Round 695 Problem B

I am getting WA on the third test case please help me where i am making mistake

link to my submisson: https://codeforces.com/contest/1467/submission/103860420

Hey @rishit517
1st thing u keep updating cnt ,i.e say if u set cnt =3 in some iteration then in next iteration u are maybe reassigning it to 1

Next thing
case

				if (hill[i]) {
					if (valley[i + 1] && valley[i - 1]) {
						cnt = 3;
					}

Here say array is 10 1 5 2 10 Here are 2 valleys and 1 hill
here u are setting cnt=3 but I dont think cnt can be 3 here .

There might be many more testcases which u are missing so my suggestion is stick to editorial