Back to problems

Find First Greater or Equal Element

Algorithm · Google · Easy

You receive two chronologically ordered lists, SoT and queries. For every value in queries, return the first value in SoT that is at least as large as that query. When SoT contains no qualifying value, return -1 instead. Design this lookup to run efficiently; binary search is an appropriate technique. Test cases: SoT: [2, 4, 6, 9, 11], queries: [1, 5, 8, 13] Output: [2, 6, 9, -1] SoT: [3, 8, 16], queries: [3, 4, 15] Output: [3, 8, 16] SoT: [4, 7], queries: [1, 4, 7, 10]…

Checking your access…