Increasing Decreasing Sequence

Link to code: https://ide.codingblocks.com/s/188628

I have tried taking into account sequences like 1,1,1,1 or 1,2,3,4,5 and other possible ones that I can think of.

Hey @icoder18, your code didn’t produce correct output for input (5,4,3,2,1). I add two lines of code to correct it.
n=int(input())
l=list()
for i in range(n):
l.append(int(input()))

def checkseq(n,l=[]):
    for i in range(n-1):
        if(l[i]>l[i+1]):
            pass
        else:
            break
    if i==n-2:
        return True
    if l[i]==l[i+1]:
        i +=1
    # print(i)
    for j in range(i,n-1):
        if(l[j]<l[j+1]):
            pass
        else:
            return False
            
    return True

print(checkseq(n,l)) 

Hope this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :blush:

There might have been a problem with the ide, because my code does contain these lines.
Here is the pastebin link to my code:
https://pastebin.com/rqceD82c

It passes all test cases except one and that is my only concern. It works fine otherwise.

Hey @icoder18, this also contains the same data.

Your code didn’t work for the input sequence [5,4,3,2,1] having length as 5. This should give true but your code gives false.

To correct this you need to add,

if i==n-2:
    return True

after first for loop as i did in above code.

Happy Learning :sunny:
Plz mark the doubt as resolved in my doubts section. :blush: