fork download
  1. #!/usr/bin/perl
  2. # your code goes here
  3.  
  4. sub getTimeDiff {
  5. my ($times) = @_;
  6.  
  7. my @times = sort {$a cmp $b} @{$times};
  8. my ($endhour, $endminute, $endsecond, $starthour, $startminute, $startsecond) = (split(':', $times[0]), split(':', $times[1]));
  9. my $diff = ($starthour * 60 * 60) + ($startminute * 60) + ($startsecond) - ($endhour * 60 * 60) - ($endminute * 60) - ($endsecond);
  10.  
  11. return $diff;
  12. }
  13.  
  14. print(getTimeDiff(["13:00:00", "13:35:17"]));
Success #stdin #stdout 0s 4880KB
stdin
Standard input is empty
stdout
2117