Skip to content

Instantly share code, notes, and snippets.

@wyukawa
Created March 29, 2019 02:22
Show Gist options
  • Save wyukawa/6d431130991dfb819f25b5e230215689 to your computer and use it in GitHub Desktop.
Save wyukawa/6d431130991dfb819f25b5e230215689 to your computer and use it in GitHub Desktop.
import edu.princeton.cs.algs4.StdIn;
public class Permutation {
public static void main(String[] args) {
int k = Integer.parseInt(args[0]);
RandomizedQueue<String> randomizedQueue = new RandomizedQueue<>();
while (!StdIn.isEmpty()) {
String str = StdIn.readString();
randomizedQueue.enqueue(str);
}
for (int i = 0; i < k; i++) {
System.out.println(randomizedQueue.dequeue());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment