0704 Binary Search
Solved at: 220904
Question
Given an array of integers nums sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.
You must write an algorithm with O(log n) runtime complexity.
Solution
Results
Runtime
- 542 ms, faster than 6.00% of Python3 online submissions for Binary Search.
Memory Usage
- 15.5 MB, less than 73.17% of Python3 online submissions for Binary Search.
Complexity Analysis
Time
Space
Backlinks (2)