Given an array containing n distinct integers in the range [0,n](inclusive of both 0 and n). Find and return number not in range | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Given an array containing n distinct integers in the range [0,n](inclusive of both 0 and n). Find and return number not in range

When nothing is missing why give zero?? Zero is already present there.Why int missingnumber =-1 not work?? Explain. https://sololearn.com/compiler-playground/cM5CzFa3Cy4t/?ref=app

19th Feb 2024, 3:19 PM
Anuj Khare
Anuj Khare - avatar
2 Answers
+ 4
Your array contains 9 elements there, but you passed 8 as the 2nd argument on the call to to `missing()` function. The for...loop inside the `missing()` function excludes <n> due to the wrong number of elements (2nd argument) passed. The task requires inclusion of both bounds of the range ( 0 ~ <n> ).
19th Feb 2024, 5:12 PM
Ipang
+ 2
DO NOT paste text in the title section, it gets cut off, nobody can read it.
19th Feb 2024, 3:23 PM
Lisa
Lisa - avatar