The code is giving runtime error. How can I combine the two functions leftindex and rightindex, if possible?
Link to code : https://ide.codingblocks.com/s/200406
Lower Upper Bound problem
Hello @Chirag-Jain-1414278322030453,
As all the conditions are same in both the functions.
The difference is of the parameters i.e. value of start and end passed.
To combine both in one function, you can return a pair of values in which first value will refer to lower bound and right will refer to the upper bound.
And you have make the changes accordingly.
But, The number of recursive calls will remain same and the time complexity will also be same.
Suggestion:
Rather keep them separate as they doesn’t make any difference together.
Hope, this would help.
Give a like if you are satisfied.