l l e c t i o n o f n u m b e r s , r e t u r n a l l p o s s i b l e p e r m u t a t i o n s . F o r e x a m p l e , [ 1 , 2 , 3 ] h a v e t h e f o l l o w i n g p e r m u t a t i o n s : [ 1 , 2 , 3 ] , [ 1 , 3 , 2 ] , [ 2 , 1 , 3 ] , [ 2 , 3 , 1 ] , [ 3 , 1 , 2 ] , a n d [ 3 , 2 , 1 ] . / / J a v a p u b l i c L i s t < L i s t < I n t e g e r > > p e r m u t e ( i n t [ ] n u m ) { L i n k e d L i s t < L i s t < I n t e g e r > > r e s = n e w L i n k e d L i s t < L i s t < I n t e g e r > > ( ) ; r e s . a d d ( n e w A r r a y L i s t < I n t e g e r > ( ) ) ; f o r ( i n t n : n u m ) { i n t s i z e = r e s . s i z e ( ) ; f o r ( ; s i z e > 0 ; s i z e - - ) { L i s t < I n t e g e r > r = r e s . p o l l F i r s t ( ) ; f o r ( i n t i = 0 ; i < = r . s i z e ( ) ; i + + ) { L i s t < I n t e g e r > t = n e w A r r a y L i s t < I n t e g e r > ( r ) ; t . a d d ( i , n ) ; r e s . a d d ( t ) ; } } } r e t u r n r e s ;