Skip to content

Commit 8a22f4d

Browse files
committed
Time: 1 ms (96.15%), Space: 44.5 MB (98.18%) - LeetHub
1 parent 8de2d0f commit 8a22f4d

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution {
2+
public List<String> getLongestSubsequence(String[] words, int[] groups) {
3+
List<String> res = new ArrayList<>();
4+
int order = -1;
5+
for (int i = 0; i < groups.length; i++) {
6+
if (groups[i] != order) {
7+
order = groups[i];
8+
res.add(words[i]);
9+
}
10+
}
11+
return res;
12+
}
13+
}

0 commit comments

Comments
 (0)