Skip to content

Commit 6ce1455

Browse files
refactor 522
1 parent c6b63bd commit 6ce1455

File tree

1 file changed

+4
-22
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+4
-22
lines changed

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

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,13 @@
33
import java.util.Arrays;
44
import java.util.Comparator;
55

6-
/**
7-
* 522. Longest Uncommon Subsequence II
8-
*
9-
* Given a list of strings, you need to find the longest uncommon subsequence among them.
10-
* The longest uncommon subsequence is defined as the longest subsequence of one of these strings and
11-
* this subsequence should not be any subsequence of the other strings.
12-
* A subsequence is a sequence that can be derived from one sequence by deleting some characters
13-
* without changing the order of the remaining elements.
14-
* Trivially, any string is a subsequence of itself and an empty string is a subsequence of any string.
15-
* The input will be a list of strings, and the output needs to be the length of the longest uncommon subsequence.
16-
* If the longest uncommon subsequence doesn't exist, return -1.
17-
18-
Example 1:
19-
Input: "aba", "cdc", "eae"
20-
Output: 3
21-
Note:
22-
23-
All the given strings' lengths will not exceed 10.
24-
The length of the given list will be in the range of [2, 50].
25-
*/
266
public class _522 {
277

288
public static class Solution1 {
29-
/**Idea: if there's such a LUS there in the list, it must be one of the strings in the given list,
30-
so we'll just go through the list and check if one string is NOT subsequence of any others, if so, return it, otherwise, return -1*/
9+
/**
10+
* Idea: if there's such a LUS there in the list, it must be one of the strings in the given list,
11+
* so we'll just go through the list and check if one string is NOT subsequence of any others, if so, return it, otherwise, return -1
12+
*/
3113
public int findLUSlength(String[] strs) {
3214
Arrays.sort(strs, new Comparator<String>() {
3315
@Override

0 commit comments

Comments
 (0)