Help for this page

Select Code to Download


  1. or download this
    sub solution_1 {
        # queue solution
        # O(2*N+M) memory, O(N^2*M) time
    ...
        pop @queue;
        print OUT "$_\n" for @queue;
    }
    
  2. or download this
    Benchmark: timing 100 iterations of Baseline, LR_1, LR_2, Queue...
      Baseline: 0.555567 wallclock secs ( 0.55 usr +  0.00 sys =  0.55 CPU
    +) @ 181.82/s (n=100)
                (warning: too few iterations for a reliable count)
    ...
    LR_1     13889/s      13%       --     -41%     -78%
    Queue    23474/s      91%      69%       --     -62%
    Baseline 62112/s     404%     347%     165%       --