Skip to content

Latest commit

 

History

History
23 lines (21 loc) · 494 Bytes

README.md

File metadata and controls

23 lines (21 loc) · 494 Bytes

Almost-Increasing-Sequence

Almost Increasing Sequence Solution in C++

bool almostIncreasingSequence(std::vector sequence) { int res=0; int max= -10000, secondmax= -10000; for (int i=0; i<sequence.size(); i++) { if (sequence[i]>max) { secondmax=max; max= sequence[i]; } else if (sequence[i]>secondmax) { max= sequence[i]; res++; } else res++; } return (res<2); }