added solution for subway problem