Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static bool AlmostIncreasingSeqeunce(int[] Sequence)
- {
- if (Sequence.Length < 3) return true;
- int i1 = 0, i2 = Sequence.Length - 1;
- for (; i1 < Sequence.Length && Sequence[i1] < Sequence[i1 + 1]; i1++) ;
- for (; i2 > 0 && Sequence[i2] > Sequence[i2 - 1]; i2--) ;
- if (Math.Abs(i1 - i2) > 1) return false;
- else if (i1 > 0) return Sequence[i1 - 1] < Sequence[i2];
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment