I didn’t understand how to approach this problem without using arrays and list.
Hackerblock link https://hack.codingblocks.com/app/contests/987/p/194
Increasing Decreasing Sequence
- Maintain 2 var : inc = 0, dec = 1
- start from second element
- check if (current > prev)
a. if dec == 1 then
dec = 0
inc = 1
b. if inc == 1
continue - else if (current <prev)
a. if dec == 1
continue
b. if inc == 1
return false - else return false
- repeat 3. until array ends
- return true
Hope it helps
Mark resolved if satisifed