@@ -11,7 +11,7 @@ class Solution {
11
11
private val charToIdx = IntArray (26 )
12
12
private val used = BooleanArray (26 )
13
13
14
- fun supersequences (words : Array <String >): MutableList < MutableList <Int ?> ? > {
14
+ fun supersequences (words : Array <String >): List < List <Int > > {
15
15
charToIdx.fill(- 1 )
16
16
for (w in words) {
17
17
used[w[0 ].code - ' a' .code] = true
@@ -37,7 +37,7 @@ class Solution {
37
37
}
38
38
// Try all supersets of forcedMask; keep those that kill all cycles
39
39
var best = 9999
40
- val goodSets: MutableList <Int ? > = ArrayList <Int ? >()
40
+ val goodSets: MutableList <Int > = ArrayList <Int >()
41
41
for (s in 0 .. < (1 shl m)) {
42
42
if ((s and forcedMask) != forcedMask) {
43
43
continue
@@ -52,16 +52,16 @@ class Solution {
52
52
}
53
53
}
54
54
// Build distinct freq arrays from these sets
55
- val seen: MutableSet <String ? > = HashSet <String ? >()
56
- val ans: MutableList <MutableList <Int ?> ? > = ArrayList <MutableList <Int ?> ? > ()
55
+ val seen: MutableSet <String > = HashSet <String >()
56
+ val ans: MutableList <MutableList <Int > > = ArrayList <MutableList <Int > >()
57
57
for (s in goodSets) {
58
58
val freq = IntArray (26 )
59
59
for (i in 0 .. < m) {
60
- freq[idxToChar[i].code - ' a' .code] = if ((s!! and (1 shl i)) != 0 ) 2 else 1
60
+ freq[idxToChar[i].code - ' a' .code] = if ((s and (1 shl i)) != 0 ) 2 else 1
61
61
}
62
62
val key = freq.contentToString()
63
63
if (seen.add(key)) {
64
- val tmp: MutableList <Int ? > = ArrayList <Int ? >()
64
+ val tmp: MutableList <Int > = ArrayList <Int >()
65
65
for (f in freq) {
66
66
tmp.add(f)
67
67
}
0 commit comments