Log in
← All problems

Binary search

mediumSorting and searching20 XP

nums is sorted from small to large with no repeats. Return the position of target, or -1 if it isn't there. Check the middle, then keep only the half that can contain the target.

Examples

Examples use JSON: true/false/null are True/False/None in Python.

Run examples checks the examples above. Submit also runs 4 hidden tests.