Java 10 lines of code for full array output

From , 3 Years ago, written in Java, viewed 219 times.
URL https://pastebin.vip/view/d0ac1ed0
  1. public class Permute{
  2.     // download from http://www.sharejs.com
  3.     static void permute(java.util.List<Integer> arr, int k){
  4.         for(int i = k; i < arr.size(); i++){
  5.             java.util.Collections.swap(arr, i, k);
  6.             permute(arr, k+1);
  7.             java.util.Collections.swap(arr, k, i);
  8.         }
  9.         if (k == arr.size() -1){
  10.             System.out.println(java.util.Arrays.toString(arr.toArray()));
  11.         }
  12.     }
  13.     public static void main(String[] args){
  14.         Permute.permute(java.util.Arrays.asList(3,4,6,2,1), 0);
  15.     }
  16. }
  17. //java/8708

Reply to "Java 10 lines of code for full array output"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website