Need Experience to Gain Experience || Infinite Application Loop
A fresher is trying to land his first job.
He applies to Company A, Company A rejects him because he lacks experience.
To gain experience, he applies to Company B. - Company B rejects him because he lacks skills.
To gain skills, he enrolls in a Course at Company C. After completing the course, he is advised to apply to Company A again.
Welcome back to Company A.
You are given a directed graph where each node represents a stage in the student's placement journey, and each directed edge represents the next step after a rejection.
Determine whether the student will eventually receive a job offer or remain trapped in an Infinite Application Loop forever.
Return:
"EMPLOYED"if there exists a path to an Offer node."WELCOME TO LINKEDIN"if the student gets stuck in a cycle with no path to an offer.
Example 1
Input
States = ["Company A", "Company B", "Course", "Offer"]
Transitions = [
["Company A", "Company B"],
["Company B", "Course"],
["Course", "Company A"]
]Output
WELCOME TO LINKEDINExplanation
Company A → Company B → Course → Company AThe student keeps getting redirected after every rejection. Since the graph contains a cycle with no path to Offer, the application process never ends.
Example 2
Input
States = ["Company A", "Internship", "Company B", "Offer"]
Transitions = [
["Company A", "Internship"],
["Internship", "Company B"],
["Company B", "Offer"]
]Output
EMPLOYEDExplanation
Company A → Internship → Company B → OfferThe internship provides the required experience, eventually leading the student to an Offer.
Constraints
1 <= Number of states <= 10^5
0 <= Number of transitions <= 2 × 10^5
