Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 74x 2x 72x 16x 56x 56x 38x 3x 12x 3x 10x 10x 30x 6x 6x 10x 4x 3x | function isSubsequence(first: string, second: string, m: number, n: number): boolean {
if (n === 0)
return true
if (m === 0)
return false
if (first[m - 1] === second[n - 1])
return isSubsequence(first, second, m - 1, n - 1)
return isSubsequence(first, second, m - 1, n)
}
export default function findLongestUncommonSubsequenceLength(
strings: string[],
): number {
let max = -1
strings.sort((a, b) => a.length - b.length)
for (let i = 0; i < strings.length; i++) {
let uniq = true
for (let j = 0; j < strings.length; j++) {
if (
i !== j
&& (strings[i] === strings[j]
|| isSubsequence(
strings[j],
strings[i],
strings[j].length,
strings[i].length,
))
) {
uniq = false
break
}
}
if (uniq)
max = Math.max(max, strings[i].length)
}
return max
}
|