← All problemsSign in

Max Graph

CodeChefRating 3306Open on judge ↗

Given an array $A$ of size $N$, construct a simple (i.e, without self-loops and multiedges) **strongly connected directed graph** with $N$ nodes where $A_i$ denotes the colour of $i^{th}$ node. The graph should satisfy the following properties: - If $A_i = A_j$, then nodes $i$ and $j$ should have the same outdegree. - If $A_i = A_j$, neither of the edges $i \to j$ and $j \to i$ should exist. - If

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