← 返回 amazon 的题目列表Maximum Length Sequence with Two Increasing-Decreasing Transitions
类型:online_judge
amazon
Question 2: Construct Monotonic Sequence
Given an integer array, construct a sequence that can be increasing, then decreasing, then increasing again, and decreasing again. Use the maximum number of numbers possible.
Input: An integer array nums.
Output: Return the maximum length of the sequence that can be formed.
Example:
nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]
Output: 9
Example
Input
1,2,2,3,3,3,4,4,5