Skip to content
We areTOP 1%

Fox And Names

MediumRating 1600CodeforcesShortest Paths & Topological Sort
Solve on Codeforces(opens in a new tab)
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews
Approach hintTry it first, then reveal

Compare each adjacent pair of names: the first differing letter gives one edge between letters, and a name followed by its own proper prefix is impossible at once. Topologically sort the 26 letters and report a cycle as impossible.

More in Shortest Paths & Topological Sort

Shortest Paths & Topological Sort questions
#ProblemPlatformDifficultyOpen1st1st Visit2nd2nd VisitRevRevise
1Course Schedule IILeetCodeMedium Solve Course Schedule II on LeetCode (opens in a new tab)
2Find Eventual Safe StatesLeetCodeMedium Solve Find Eventual Safe States on LeetCode (opens in a new tab)
3Network Delay TimeLeetCodeMedium Solve Network Delay Time on LeetCode (opens in a new tab)
4Path With Minimum EffortLeetCodeMedium Solve Path With Minimum Effort on LeetCode (opens in a new tab)
5Cheapest Flights Within K StopsLeetCodeMedium Solve Cheapest Flights Within K Stops on LeetCode (opens in a new tab)
6Find the City With the Smallest Number of Neighbors at a Threshold DistanceLeetCodeMedium Solve Find the City With the Smallest Number of Neighbors at a Threshold Distance on LeetCode (opens in a new tab)
7Number of Ways to Arrive at DestinationLeetCodeMedium Solve Number of Ways to Arrive at Destination on LeetCode (opens in a new tab)
8Fox And NamesCodeforcesMedium 1600Solve Fox And Names on Codeforces (opens in a new tab)
9The Two RoutesCodeforcesMedium 1600Solve The Two Routes on Codeforces (opens in a new tab)
10Greg and GraphCodeforcesMedium 1700Solve Greg and Graph on Codeforces (opens in a new tab)
11SubstringCodeforcesMedium 1700Solve Substring on Codeforces (opens in a new tab)
12LabyrinthCodeforcesHard 1800Solve Labyrinth on Codeforces (opens in a new tab)
13BicyclesCodeforcesHard 1800Solve Bicycles on Codeforces (opens in a new tab)
14Parallel Courses IIILeetCodeHard Solve Parallel Courses III on LeetCode (opens in a new tab)
15Dijkstra?CodeforcesHard 1900Solve Dijkstra? on Codeforces (opens in a new tab)

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account