Reverse Costs
For $2$ arrays $A$ and $B$, both of length $N$, we define $f(A, B)$ as follows: - An integer $s$ is said to be good if it is possible to transform $A$ to $B$ using the following operation several (possibly $0$) times: - Choose a range $(l, r)$ such that $(r - l + 1) \ge s$ and $1 \le l \le r \le N$. - Reverse the subarray $[A_l, A_{l + 1}, \ldots, A_r]$. - $f(A, B)$ is defined as
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