Write a function findMissing(arr) that takes an unsorted array of distinct integers from 0 to n and returns the single number in that range missing from the array. For example, findMissing([3, 0, 1]) should return 2, and findMissing([0, 1, 2, 4, 5]) should return 3.
function findMissing(arr) {
// your code here
}
Rules:
- The input array contains distinct integers from 0 to n with exactly one value missing.
- Do not use external libraries.
- Return the single missing integer.
Post your solution as a reply. Answer goes up in about a day.