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)); } } } }