- 1

Consider an array consisting of the following sequence: 1,2,3,4,5,…..,n. Suppose a number in the sequence is missing.

Write the mathematical process to find the missing number, i.e. some equation. What is the time complexity of finding the missing number in the sequence?

6th Aug 2020, 9:33 AM
hizb Ullah
hizb Ullah - avatar
2 ответов
0
Check using for i in array for array[i] !== i-1 ; alert("something is wrong daya" );
6th Aug 2020, 9:41 AM
Divya Mohan
Divya Mohan - avatar
+ 2
You will just need to compare the sequence in the array with an equation that matches the specific pattern, the number you store is the one that doesn't match the equation. just make sure when iterating through the array that each number is matched as the rest of the pattern wont be in sync with the equation. 1 1+1 2 2+1 4 3+1 //pattern breaks here. 5 4+1 6 5+1
6th Aug 2020, 9:53 AM
D_Stark
D_Stark - avatar