Phone Screen - SOLUTION
Problem
If you were given a list of n integers and knew that they were sorted, how quickly could you check if a given integer was in the list? Elaborate on your reasoning and search methods in general
Requirements
Try explaining your solution to someone and see if it makes sense ot them. Don‘t code anything for this problem
Solution
Hopefully this problem sounds familiar! We can use a binary search to search for an intger since the list is already sorted! This means we can find the item in O(logn) time and O(1) space!
Revisit the lectures on Binary Search and its implementation to fully get the reasoning behind this solution and problem!
Good Job!
时间: 2024-10-03 21:38:31