Skip to content

Instantly share code, notes, and snippets.

@MichaelaIvanova
Created July 14, 2017 15:32
Show Gist options
  • Select an option

  • Save MichaelaIvanova/e422c0f4bcdad85a738295ef99a8434d to your computer and use it in GitHub Desktop.

Select an option

Save MichaelaIvanova/e422c0f4bcdad85a738295ef99a8434d to your computer and use it in GitHub Desktop.
public static int solution(int[] A)
{
var maxDepth = int.MaxValue;
var counter = 0;
for (int i = 1; i < A.Length - 1; i++)
{
var current = A[i];
var previous = A[i - 1];
var next = A[i + 1];
if (previous > current && current <= next)
{
if (current < maxDepth)
{
maxDepth = current;
}
}
}
return maxDepth;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment