Help for this page

Select Code to Download


  1. or download this
    # time = O(N)   memory = O(N*M)
    
    my $count = map @$_, values %h;
    
  2. or download this
    # time = O(N)   memory = O(N)
    
    my $count = sum map { scalar @$_ } values %h;
    
  3. or download this
    # time = O(N)   memory = O(N)
    
    my $count = 0;
    $count += @$_ for values %h;
    
  4. or download this
    # time = O(N)   memory = O(1)
    
    ...
    while (my ($k, $v) = each(%h)) {
       $count += @$v;
    }