* Determine whether an array contains a permutation of the integers from 0 to the array's length - 1 * @param {Array} inds * @return {boolean}
(inds)
| 488 | * @return {boolean} |
| 489 | */ |
| 490 | function isRangePermutation(inds) { |
| 491 | var indsSpecified = new Array(inds.length); |
| 492 | |
| 493 | for(var i = 0; i < inds.length; i++) { |
| 494 | // Check for out of bounds |
| 495 | if(inds[i] < 0 || inds[i] >= inds.length) { |
| 496 | return false; |
| 497 | } |
| 498 | |
| 499 | // Check for collisions with already specified index |
| 500 | if(indsSpecified[inds[i]] !== undefined) { |
| 501 | return false; |
| 502 | } |
| 503 | |
| 504 | indsSpecified[inds[i]] = true; |
| 505 | } |
| 506 | |
| 507 | // Nothing out of bounds and no collisions. We have a permutation |
| 508 | return true; |
| 509 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…