Increasing Decreasing sequence

Kindly explain how to solve this without using arrays. I am unable to reach the logic behind

Refer this: Increasing Deccreasing Sequence

You need to find the point where the nature of input stream changes. So, after going from strictly decreasing to strictly increasing, if it changes its nature again the ans is false else true.

1 Like

Still could not get the logic involved :frowning:

I am trying as you advised

There can be 2 cases:

  1. Whole input stream is strictly increasing/decreasing, ans is true since it can be broken into two sequences such as first element first sequence and the rest of elements another sequence.
  2. Keep a flag which changes its value as soon as it finds an element greater than equal to last input element. So, from now on here if the whole sequence is strictly increasing then ans is true else false.
1 Like

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.

I have not yet correctly completed the code…I shall revert u back soon.

Unable to solve this :frowning: Kindly help with the code and logic building

Please reopen the doubt so that I can solve your doubt personally over the chat.