Tap here to switch tabs
Problem
Submissions

Problem: Wiggle Subsequence

med
30 min
Try to solve the Wiggle Subsequence problem.

Statement

A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference may be either positive or negative. A sequence with fewer than two elements is also considered a wiggle sequence.

Given an integer array nums, return the length of the longest subsequence of nums that is a wiggle sequence.

A subsequence is obtained by deleting some elements from nums without changing the order of the remaining elements.

Note: A subsequence is obtained by deleting some elements from nums without changing the order of the remaining elements.

Constraints:

  • 1 \leq nums.length \leq 1000

  • 0 \leq nums[i] \leq 1000

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Wiggle Subsequence

med
30 min
Try to solve the Wiggle Subsequence problem.

Statement

A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative. The first difference may be either positive or negative. A sequence with fewer than two elements is also considered a wiggle sequence.

Given an integer array nums, return the length of the longest subsequence of nums that is a wiggle sequence.

A subsequence is obtained by deleting some elements from nums without changing the order of the remaining elements.

Note: A subsequence is obtained by deleting some elements from nums without changing the order of the remaining elements.

Constraints:

  • 1 \leq nums.length \leq 1000

  • 0 \leq nums[i] \leq 1000