Increasing Decreasing Sequence

Test cases failed

Hi @itzsakshi26gupta

Problem is in taking input, your code isn’t taking input properly which results in run-time error. So, you can modify your input function like this https://ide.codingblocks.com/s/151813.

Reason: your input function will work fine if input is space separated but if you’ll check the sample input, every input number is coming in a new line.

Apart from this, there is a small logical mistake in your code. Its mentioned in the problem clearly that sequence should be strictly dec or strictly inc, So, strictly means 2 equal no.s should not be present consecutively in the sequence. For this, update your if checks

if l[i-1]>=l[i]: as if l[i-1]>l[i]:

and

if l[i-1]<=l[i]: as if l[i-1]<l[i]:

I hope this will help you :slight_smile: If you have any further doubt then please feel free to respond to this thread.

The only difference between your solution and my solution(regarding taking input) is that you are using insert function in the list whereas I am using append function. So was the issue just because of using the wrong function? If yes, then please describe the difference between the two.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.