两道跟circular linkedlist相关的题。# JobHunting - 待字闺中
i*7
1 楼
第一题是求一个循环链表的最大和的子链表。
譬如说 1 -> -1 -> 2。然后又回到1,最大和是3,子链表是 2 -> 1。
第二题如下。
There are n gas stations positioned along a circular road. Each has a
limited supply of gas. You can only drive clockwise around the road. You
start with zero gas. Knowing how much gas you need to get from each gas
station to the next and how much gas you can get at each station, design an
algorithm to find the gas station you need to start at to get all the way
around the circle.
跪求各位大神,求思路求解答。
譬如说 1 -> -1 -> 2。然后又回到1,最大和是3,子链表是 2 -> 1。
第二题如下。
There are n gas stations positioned along a circular road. Each has a
limited supply of gas. You can only drive clockwise around the road. You
start with zero gas. Knowing how much gas you need to get from each gas
station to the next and how much gas you can get at each station, design an
algorithm to find the gas station you need to start at to get all the way
around the circle.
跪求各位大神,求思路求解答。