<awangdev>47. Permutations II_1.java
private void dfs(List<List<Integer>> rst, List list, Queue<Integer> queue) {

        if (queue.isEmpty()) { 
            rst.add(new ArrayList<>(list));
            return;
        }
        int size = queue.size(); 
        Integer last = null;
        while (size-- > 0) {
            int val = queue.poll();
            if (last != null && last == val) {
                queue.offer(val);
                continue;
            }
            list.add(val);
            dfs(rst, list, queue);
            list.remove(list.size() - 1); 
            queue.offer(val);
            last = val;
        }
    }
private void sample_funcname ( List < List < Integer >> rst , List list , Queue < Integer > queue ) {
  if ( queue . isEmpty ( ) ) {
    rst . add ( new ArrayList < > ( list ) ) ;
    return ;
  }
  int size = queue . size ( ) ;
  Integer last = null ;
  while ( size -- > 0 ) {
    int val = queue . poll ( ) ;
    if ( last != null && last == val ) {
      queue . offer ( val ) ;
      continue ;
    }
    list . add ( val ) ;
    dfs ( rst , list , queue ) ;
    list . remove ( list . size ( ) - 1 ) ;
    queue . offer ( val ) ;
    last = val ;
  }
}
