I've added a condition that checks if an array is empty and automatically set an integer to larger than the size of the array since it's empty, but i get an "Index was outside the bounds of the array." mesage instead
public static bool hurdleJump(int[] hurdles, int jumpHeight)
{
int max = hurdles[0];
if (hurdles == null && hurdles.Length == 0)
{
return false;
}
else if (hurdles != null || hurdles.Length >= 1)
{
for (int i = 0; i < hurdles.Length - 1; i++)
{
max = max < hurdles[i+1] ? hurdles[i+1] : max;
}
if (jumpHeight >= max)
{
return true;
}
}
return false;
}
static void Main(string[] args)
{
Console.WriteLine(hurdleJump(new int[] {}, 7));
}