← Microsoft questions

Order Prisoners Based on Mutual Hatred Relationships

Filed under Microsoft

Given N prisoners and M directed hatred constraints (A hates B), determine if a valid linear ordering exists where no prisoner hates a successor. If a cycle exists, return an empty list; otherwise…

You've read your 3 free write-ups

Sign up free to keep reading. Your account opens the first 10 questions of every company.

Related Microsoft questions

Collected from public candidate posts and coding forums. Updated Nov 2026.