|
3 | 3 | import java.util.Arrays;
|
4 | 4 | import java.util.Comparator;
|
5 | 5 |
|
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 |
| - */ |
26 | 6 | public class _522 {
|
27 | 7 |
|
28 | 8 | 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 | + */ |
31 | 13 | public int findLUSlength(String[] strs) {
|
32 | 14 | Arrays.sort(strs, new Comparator<String>() {
|
33 | 15 | @Override
|
|
0 commit comments