Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

PermCheck: Check whether array A is a permutation.

function isPermutation(arr)
{
var isPermutation = true;

arr.sort(function(a, b){return a - b});

for(var i = 0; i<arr.length-1; i++)
{
if(arr[i]+1!=arr[i+1])
{

isPermutation = false;
}

}

return isPermutation;
}
Source by ankeetmaini.dev #
 
PREVIOUS NEXT
Tagged: #Check #array #A
ADD COMMENT
Topic
Name
1+6 =