Check if words chain to form a circle

medium