01 April 2017

almostIncreasingSequence

My solution:
bool almostIncreasingSequence(int[] sequence)
{
    bool erased = false;
    for (int i = sequence.Length - 1; i > 0; i--)
        if (sequence[i] <= sequence[i - 1])
            if (erased != true)
                erased = true;
            else
                return false;

    return true;
}

Previous Next