<gouthampradhan>backtracking_Permutations_1.java
private void nextPermutation(int i, int[] nums, List<List<Integer>> result) {
    if (i == nums.length - 1) {
      List<Integer> list = new ArrayList<>();
      for (int n : nums) list.add(n);
      result.add(list);
    } else {
      for (int j = i, l = nums.length; j < l; j++) {
        int temp = nums[j];
        nums[j] = nums[i];
        nums[i] = temp;
        nextPermutation(i + 1, nums, result);
        temp = nums[j];
        nums[j] = nums[i];
        nums[i] = temp;
      }
    }
  }
private void sample_funcname ( int i , int [ ] nums , List < List < Integer >> result ) {
  if ( i == nums . length - 1 ) {
    List < Integer > list = new ArrayList < > ( ) ;
    for ( int n : nums ) list . add ( n ) ;
    result . add ( list ) ;
  }
  else {
    for ( int j = i , l = nums . length ;
    j < l ;
    j ++ ) {
      int temp = nums [ j ] ;
      nums [ j ] = nums [ i ] ;
      nums [ i ] = temp ;
      nextPermutation ( i + 1 , nums , result ) ;
      temp = nums [ j ] ;
      nums [ j ] = nums [ i ] ;
      nums [ i ] = temp ;
    }
  }
}
