Question bank › Graphs Dfs
Dsa Graphs Dfs Medium

The Chronological Vault

An archaeologist is exploring a network of N chambers (0 to N-1) connected by M one-way tunnels. Each chamber has a known 'relic year'—the age of the artifacts inside. To maintain the narrative of time, the archaeologist wants to find the longest possible path through the chambers such that the relic years are strictly decreasing. Input Format: - Line 1: Two integers N and M. - Line 2: N integers representing the relic year of each chamber from 0 to N-1. - Next M lines: Two integers U and V representing a one-way tunnel from U to V. Output Format: - A single integer representing the maximum number of chambers in a valid decreasing-year path. Example: Input: 4 3 10 8 5 12 0 1 1 2 3 0 Output: 4 (Explanation: Path 3 -> 0 -> 1 -> 2 corresponds to years 12, 10, 8, 5, which is strictly decreasing.)

Key concepts

graphs_dfsmemoizationdag

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.