Creating Main Class

public static void Main()
{
    int[] arr = { 1, 56, 58, 57, 90, 92, 94, 93, 91, 45 };
    int n = arr.Length;
    Console.WriteLine("Length of the longest contiguous subarray is " + findLength(arr, n));
}

Beside that, we will making two utility functions for comparing two elements.

// Utility functions to find minimum and maximum of
// two elements

static int min(int x, int y)
{
    return (x < y) ? x : y;
}

static int max(int x, int y)
{
    return (x > y) ? x : y;
}

results matching ""

    No results matching ""