Advertisement
jules0707

Permutation.java

Feb 19th, 2018 (edited)
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1. import edu.princeton.cs.algs4.StdIn;
  2. import edu.princeton.cs.algs4.StdOut;
  3.  
  4. public class Permutation {
  5.     public static void main(String[] args) {
  6.        
  7.         RandomizedQueue<String> q = new RandomizedQueue<String>();
  8.         int k = Integer.parseInt(args[0]);     
  9.        
  10.         while (!StdIn.isEmpty()) {
  11.             String s = StdIn.readString();
  12.             q.enqueue(s);
  13.         }
  14.  
  15.         for (int i = 0; i < k; i++) {
  16.             StdOut.print(q.dequeue() + "\n");
  17.         }
  18.  
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement