Rippling interview question

Bus Route question ( available in leetcode)