Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. package com.hackerearth.test;
  2.  
  3. public class PowerSetGeneration {
  4.  
  5. public static void main(String[] args) {
  6. permute("", "ball");
  7.  
  8. }
  9.  
  10. private static void permute(String prefix, String test) {
  11. int n = test.length();
  12. if (n == 0) {
  13. System.out.println(prefix);
  14. } else {
  15. for (int i = 0; i < n; i++) {
  16. permute(prefix + test.charAt(i),
  17. test.substring(0, i) + test.substring(i + 1));
  18.  
  19. }
  20. }
  21.  
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement