i wrote my own code. i shows wrong output. debug?
Own code error. check
Hello @priyamthakuria27,
Mistakes in your code:
-
Value of e.
Correction:
e = a[n - 1] - a[0]+1; -
The mid is not necessarily be the answer.
Solution:
Rather use a separate variable. -
Int datatype is not appropriate to satisfy the given constraints.
-
Wrong initial value of the for loop.
for (int i = 0; i < n; i++) {
Correction:
for (int i = 1; i < n; i++) {
Refer to the following code:
Hope, this would help.