← All problemsSign in

Mex Path

CodeChefRating 3325Open on judge ↗

You're given an array $A$ of size $N$. There is a [complete](https://en.wikipedia.org/wiki/Complete_graph) [weighted](https://en.wiktionary.org/wiki/weighted_graph) graph with $N$ nodes and $\frac{N \cdot (N-1)}{2}$ undirected weighted edges. The weight of edge between node $i$ and node $j$ is determined as $\text{MEX}(A_i, A_{i+1}, \ldots, A_j)$. Your task is to find the [shortest path](http

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.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start