Qualified's blog

By Qualified, history, 4 years ago, In English

Given an integer $$$n$$$, $$$1 <= n <= 10^5$$$, and an array $$$a$$$ consisting of $$$n$$$ elements, figure out if the array is a good array. A good array is defined to be first increasing, then decreasing. Note that an increasing array or decreasing array is a good array. An increasing array is an array such that every next element of every element(that is not the last) has to be greater than or equal to that element. A decreasing array is an array such that every next element of every element(that is not the last) has to be less than or equal to that element.

Example:

Input:

5 1 2 4 3 1

Output: YES

Input:

3 3 2 1

Output: YES

Input:

5 1 2 3 4 4

Output: YES

Input:

5 5 4 2 1 1

Output: YES

  • Vote: I like it
  • -39
  • Vote: I do not like it

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

The second example is currently wrong.

Also, you can look at the respective problem's solutions, filter by language, read the implementations, and cut out this subproblem. You will soon find the one you like.

»
4 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Auto comment: topic has been updated by Qualified (previous revision, new revision, compare).