+ 1

help please 😢

An array containing 5 non-negative integers is given. A pit is a non-edge element of an array that is smaller than both of its neighbors. It is necessary to find the deepest pit in the array, that is, the pit whose value is minimal. If there is no pit in the array, the answer is considered equal to 0. For example, in an array of six elements equal to 4, 9, 2, 17, 3, 8, respectively, there are two pits - 2 and 3, the deepest pit - 2. I have two solutions. I wrote the first myself. The second solution is the real answer to this problem. Tell me whether my solution (version 1) is suitable for this task or not https://code.sololearn.com/cq1ef3tOWL1P/?ref=app

9th Apr 2020, 4:47 PM
shiryaeva
shiryaeva - avatar
3 Respostas
+ 1
🤕
9th Apr 2020, 5:11 PM
shiryaeva
shiryaeva - avatar
+ 1
Your code fails for [1, 4, 2, 4, 1]. The expected output is 2, yours is 1. Hint: What happens if the first element, namely "a[0]", is less than all of the pits?
9th Apr 2020, 6:52 PM
Diego
Diego - avatar
0
The answer is "aaa".
9th Apr 2020, 10:39 PM
lojeen qais
lojeen qais - avatar