Company: PLUTUS_RESEARCH_IITR
Difficulty: medium
Building Exit and Loop Detection Problem Description There are n floors in a building. You are given an array of integers of size n . The value at the i -th index represents the floor where you can go from floor i . If the value is -1 , it means you can exit the building. You have to detect whether you can exit the building or not. If yes, return the string "can exit!" . If not, tell from where the loop starts (let's say at floor X ) and return the string "loop starts at floor X" . Examples Example 1: Input: arr = [1,2,3,4,2] Output: "loop starts at floor 2" Explanation: Starting from floor 0, the path is 0 -> 1 -> 2 -> 3 -> 4 -> 2. A loop exists starting at floor 2. Constraints n up to 10 5