NeetCode #555LC-2940HardHeap / Priority Queue
← Back to All Problems

#555 · #2940 · Find Building Where Alice and Bob Can Meet(找到 Alice 和 Bob 可以相遇的建筑)

📌 Problem Statement & Constraints

You are given an array heights and queries where queries[i] = [a, b]. For each query, find the leftmost index c such that max(a, b) < c and heights[c] > max(heights[a], heights[b]). If a == b or heights[max(a,b)] > heights[min(a,b)], the answer is max(a, b). Return -1 when no such index exists. Constraints: 1 <= heights.length, queries.length <= 5 * 10^4.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!