You are viewing a single comment's thread. Return to all comments →
Could someone help take a look why this fails?
n = input() for _ in range(int(n)): m = int(input()) l, r = 0, m - 1 c = float('inf') array = input() array = list(map(int, array.split(" "))) ans = 'Yes' while l <= r: if c <= min(array[l], array[r]): ans = 'No' break if (c >= array[l]) and (c >= array[r]): if (array[l] >= array[r]): c = array[l] l += 1 else: c = array[r] r -= 1 elif c >= array[l]: c = array[l] l += 1 else: c = array[r] r -= 1 print(ans)
Seems like cookies are disabled on this browser, please enable them to open this website
Piling Up!
You are viewing a single comment's thread. Return to all comments →
Could someone help take a look why this fails?