注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
Question 2 — Count Paths
Objective It's back-to-school time! In order to buy school supplies for your kids, you have to go to 4 different types of shop:
- a bookshop to buy a workbook,
- a school shop to buy some glue,
- a sport store to buy a pair of sneakers,
- a stationery store to buy a pencil.
Shopping for school isn't a fun hobby for you, so you started to search for the shortest counts as two valid paths.
There are a maximum of 50 shops and 250 roads.
Example
With these inputs:- shops = [1, 0, 3, 2, 2]roads = [ [0, 1], [1, 2], [1, 4], [2, 3], [2, 4]]
复制代码 The valid paths are below, each list contains the 4 shop indexes to visit:- [0, 1, 2, 3][0, 1, 2, 4][0, 1, 4, 2][3, 2, 1, 0][4, 2, 1, 0][2, 4, 1, 0]
复制代码 As there are 6 solutions, your code must output:
求加米~~~ |