The array of natural numbers (up to and including n), passed to "findMissed" function. The numbers in array are unordered and each number occurs once. Ð’ut one number is missing. I need to determine which one is missed and return it. For the computational complexity to be O(n).
Can I use JS sort() function in solution, and then "for"
function findMissed(arr) {
arr.sort();
for (let i = 0; i <= arr.length; i++) {
...
}
}
or it will be more complex than O(n)?