Need to generate superset in java
问题 Trying to figure out a way to generate a superset using java need simple answer to what am looking for is Input : ab Output : {} {a} {b} {ab} how do i go about this any clue ? Thanks in advance 回答1: int allMasks = (1 << N); for (int i = 1; i < allMasks; i++) { for (int j = 0; j < N; j++) if ((i & (1 << j)) > 0) //The j-th element is used System.out.print((j + 1) + " "); System.out.println(); } 回答2: Since this is currently the second result in google for java superset I'm going to answer that