Increasing decreasing sequence

I unlocked the editorial but I guess its implementation is beyond what is taught till now.so can I get an easy implementation for this

Hello @lakshit

First give this question a try and then post the whatever code you would have written.

Hint to solve:-
Take int i = 0

do i++ until (arr[i] > arr[i+1] && i < n)

Then

do i++ until (arr[i] < arr[i+1] && i < n)

if(i == n) then sequence is decreasing increasing else NOT.

since according to course arrays were not taught before this question ,so i wanted to solve the question without use of arrays.So is it possible ??

Hello @lakshit

Yes, you can solve it without using arrays
you can repeatedly take inputs within a while loop

Hint to solve:-
Take int i = 0;
First you can repeatedly take inputs while the current number is greater than next and increment ā€œiā€ each time
Then you can repeatedly take inputs while the current number is less than the next and increment ā€œiā€ each time
Now if the sequence is strictly decreasing-increasing all the inputs must be exhausted so ā€œiā€ should be equal to n now