NeetCode #897LC-1538MediumMath & GeometryNC Algo100
← Back to All Problems#897 · #1538 · Guess the Majority in a Hidden Array(找出隐藏数组中出现次数最多的值)
📌 Problem Statement & Constraints
This is an interactive problem, so it cannot be run offline: the hidden binary array is only reachable through the provided
ArrayReader API. reader.length() returns n; reader.query(a, b, c, d) takes four strictly increasing indices 0 <= a < b < c < d < n and returns 4 if all four values are equal, 2 if exactly three are equal, and 0 if the four values split two-and-two. Return the index of any value that appears more than n / 2 times, or -1 if there is no majority. Constraints: 4 <= n <= 10^5, at most 2n calls to query.🔒
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!