For instance, given ( 1, 2, 5, 6, 7), i'd like to determine that 3 and 4 are missing?
I've found following code which achieves my goal.
#!/usr/bin/perl
use Data::Dumper;
@list= (1,2,5,6,7);
@missing = map $list[$_-1]+1..$list[$_]-1, 1..@list-1;
print Dumper(\@missing);
Output:
$VAR1 = [
3,
4
];
Can someone please explain the logic behind above code?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)