Skip to content

Commit 4513244

Browse files
refactor 376
1 parent 0a414ae commit 4513244

File tree

1 file changed

+0
-32
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+0
-32
lines changed

src/main/java/com/fishercoder/solutions/_376.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,5 @@
11
package com.fishercoder.solutions;
22

3-
/**
4-
* 376. Wiggle Subsequence
5-
*
6-
* A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly
7-
* alternate between positive and negative.
8-
* The first difference (if one exists) may be either positive or negative.
9-
* A sequence with fewer than two elements is trivially a wiggle sequence.
10-
11-
For example, [1,7,4,9,2,5] is a wiggle sequence because the differences
12-
(6,-3,5,-7,3) are alternately positive and negative.
13-
In contrast, [1,4,7,2,5] and [1,7,4,5,5] are not wiggle sequences,
14-
the first because its first two differences are positive and the second because its last difference is zero.
15-
16-
Given a sequence of integers, return the length of the longest subsequence that is a wiggle sequence.
17-
A subsequence is obtained by deleting some number of elements (eventually, also zero)
18-
from the original sequence, leaving the remaining elements in their original order.
19-
20-
Examples:
21-
Input: [1,7,4,9,2,5]
22-
Output: 6
23-
The entire sequence is a wiggle sequence.
24-
25-
Input: [1,17,5,10,13,15,10,5,16,8]
26-
Output: 7
27-
There are several subsequences that achieve this length. One is [1,17,10,13,10,16,8].
28-
29-
Input: [1,2,3,4,5,6,7,8,9]
30-
Output: 2
31-
32-
Follow up:
33-
Can you do it in O(n) time?
34-
*/
353
public class _376 {
364

375
public static class Solution1 {

0 commit comments

Comments
 (0)