judge ми дава лимит за време на PHP на 10. Pairs by Difference от Arrays - Exercises
<?php
//Write a program that count the number of pairs in given array which difference is equal to given number.
// The first line holds the sequence of numbers.
// The second line holds the difference.
//1 5 3 4 2
//2
$num=readline();
$num_arr=explode(" ",$num);
$len=count($num_arr);
$control=readline();
$counter=0;
for($i=0;$i<$len;$i++)
{
for($j=$i+1;$j<$len;$j++)
{
if (abs($num_arr[$i]-$num_arr[$j])==$control)
{
$counter++;
}
}
}
echo $counter;
Някакви идеи?! Благодаря предварително!