Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.hackerearth.test;
- public class PowerSetGeneration {
- public static void main(String[] args) {
- permute("", "ball");
- }
- private static void permute(String prefix, String test) {
- int n = test.length();
- if (n == 0) {
- System.out.println(prefix);
- } else {
- for (int i = 0; i < n; i++) {
- permute(prefix + test.charAt(i),
- test.substring(0, i) + test.substring(i + 1));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement