Check connectivity between two subway stations | Bloomberg Coding Question