Note c > 1 condition is required to make sure that a single column row is not counted twice ( Note that a single column row is sorted both in increasing and decreasing order )
if c > 1 and j == 1 : NEW_LINE INDENT result += 1 NEW_LINE DEDENT return result NEW_LINE