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) {
4949 continue ;
5050 }
5151 int size = Integer .bitCount (s );
52- if (size > best ) {
53- continue ;
54- }
55- if (!hasCycle (s )) {
52+ if (size <= best && !hasCycle (s )) {
5653 if (size < best ) {
5754 best = size ;
5855 goodSets .clear ();
@@ -83,10 +80,8 @@ public List<List<Integer>> supersequences(String[] words) {
8380 private boolean hasCycle (int mask ) {
8481 int [] color = new int [m ];
8582 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 ;
9085 }
9186 }
9287 return false ;
You can’t perform that action at this time.
0 commit comments