This is a verified interview question from Linkedin. Candidates reporting seeing this problem in recent Online Assessments (OAs) and onsite rounds. Mastering "Orient Graph - Linkedin Online Assessment IIT Kanpur" covers key patterns like Graphs.
"You are given a graph with n vertices numbered from 1 to n. The graph contains m edges. However, for every edge, only its two endpoints are given. The direction of each edge is unknown and may be chosen arbitrarily. You are also given an ordering of all vertices representing a traversal. Determine whether it is possible to assign a direction to every edge such that the given ordering is a valid traversal of the graph. Print "YES" if such an assignment exists; otherwise print "NO"."
Join thousands of developers practicing for Linkedin.