Suppose that we have a product company & we have a product manager leading a team to develop a new product. Unfortunately, the latest version of our product fails the quality check
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
total answers (1)
Of course this is a searching problem & for optimization we can do a binary search here. But now the question is, is there any other optimum searching method for search problem? The answer is yes.
It is binary search but the narrow down constant, K is not typically (low + high)/2 as in case of general binary search.
In this case the narrow down constant, K= low+(high-low)/2 resulting in much more optimized result.
Algorithm:
We have already the API function bool isBadVersion(version)
Now to find the first bad version we generate another function:
low=lower bound variable
high=upper bound variable
C++ implementation
Output