Top 2 Max
Given an integer $N$, let $S$ denote the set of integers from $1$ to $N$ (inclusive). You are given a function $f : S \times S \rightarrow S$, such that $f(x, y) = f(y, x)$. For an array $A$, we define it's value as following: - The score of a subarray (of size at least $2$) is defined as : - let $M_1$ be the maximum element in the subarray, and $M_2$ be the second maximum element in the s
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start