收到ThoughtWorks的面试邀请,HR电话初面后,说是要做题。
给发了3道题,任选一道。
ThoughtWorks是什么样的公司呢?外企,听说很牛,什么“敏捷开发模式”就是那公司
首创的概念。出的题目也有些奇怪,选取第一道如下:
Problem one: Trains
The local commuter railroad services a number of towns in Kiwiland. Because of monetary concerns, all of the tracks are ‘one-way.’ That is, a route from Kaitaia to Invercargill does not imply the existence of a route from Invercargill to Kaitaia. In fact, even if both of these routes do happen to exist, they are distinct and are not necessarily the same distance!
The purpose of this problem is to help the railroad provide its customers with information about the routes. In particular, you will compute the distance along a certain route, the number of different routes between two towns, and the shortest route between two towns.
Input: A directed graph where a node represents a town and an edge represents a route between two towns. The wei