Company: Tredence analyst_5nov
Difficulty: medium
Escalator Loop Detection Problem Description A shopping mall has an automated escalator system where people move between floors using escalators. Each floor is connected to the next floor via an escalator, allowing people to travel up or down based on the system's settings. Due to a malfunction, some escalators are causing people to enter an infinite loop, meaning instead of reaching an exit floor, they keep moving between a set of floors indefinitely. Your task is to detect if the escalator system contains a loop, meaning a person keeps moving in a cycle instead of reaching the exit. Input Format The first line contains an integer N (1 ≤ N ≤ 10 5 ), the number of floors in the system. The next line contains N space-separated integers, where the ith integer represents the next floor a person will move to from floor i (index starts from 0). If -1 is given, it means the person exits from that floor. Output Format If there is a loop, print "Loop Detected at Floor X", where X is the