Algorithm · Karat · Easy
A castle contains a number of rooms, and every room bears the name of a flower. Inside each room is a single instruction that directs you to exactly one next room. A subset of the rooms are designated as treasure rooms. Implement a function that finds every room meeting both of these conditions: at least two other rooms have instructions that point to it, and its own instruction sends you directly to a treasure room. Return all rooms that satisfy both conditions. Examples…