File tree Expand file tree Collapse file tree 1 file changed +3
-8
lines changed
src/main/java/g3401_3500/s3435_frequencies_of_shortest_supersequences Expand file tree Collapse file tree 1 file changed +3
-8
lines changed Original file line number Diff line number Diff line change @@ -49,10 +49,7 @@ public List<List<Integer>> supersequences(String[] words) {
49
49
continue ;
50
50
}
51
51
int size = Integer .bitCount (s );
52
- if (size > best ) {
53
- continue ;
54
- }
55
- if (!hasCycle (s )) {
52
+ if (size <= best && !hasCycle (s )) {
56
53
if (size < best ) {
57
54
best = size ;
58
55
goodSets .clear ();
@@ -83,10 +80,8 @@ public List<List<Integer>> supersequences(String[] words) {
83
80
private boolean hasCycle (int mask ) {
84
81
int [] color = new int [m ];
85
82
for (int i = 0 ; i < m ; i ++) {
86
- if (((mask >> i ) & 1 ) == 0 && color [i ] == 0 ) {
87
- if (dfs (i , color , mask )) {
88
- return true ;
89
- }
83
+ if (((mask >> i ) & 1 ) == 0 && color [i ] == 0 && dfs (i , color , mask )) {
84
+ return true ;
90
85
}
91
86
}
92
87
return false ;
You can’t perform that action at this time.
0 commit comments