-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPermutation.java
More file actions
31 lines (24 loc) · 804 Bytes
/
Copy pathPermutation.java
File metadata and controls
31 lines (24 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* *****************************************************************************
* Name: Rafael Neves Moraes
*
* Description: Permutation algorithm.
*
* Written: 5/06/2019
*
* % javac Permutation.java
* % java Permutation
*
**************************************************************************** */
import java.util.Iterator;
import edu.princeton.cs.algs4.StdIn;
public class Permutation {
public static void main(String[] args) {
int count = Integer.parseInt(args[0]);
RandomizedQueue<String> deq = new RandomizedQueue<>();
while (!StdIn.isEmpty())
deq.enqueue(StdIn.readString());
Iterator<String> it = deq.iterator();
for (int i = 0; i < count; i++)
System.out.println(it.next());
}
}