Partition
You are given an array $A$ of $N$ integers. A **partition** of $A$ is a sequence of $x$ $(1 \le x \le N)$ contiguous subarrays $B_1, B_2, \ldots, B_x$ such that their concatenation equals $A$. For a subarray $B_i$, let $g(B_i)$ denote the maximum frequency of any element in $B_i$. The **score** of a partition is defined as: $$f = \sum_{i=1}^{x} g(B_i)$$ Find the number of **distinct** values o
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