Algorithm for truck moving around a circle of gas stations

前端 未结 11 1384
陌清茗
陌清茗 2020-12-13 07:08

You have a truck moving around a circular track with gas stations spaced out around the circle. Each station has a finite amount of gas. The gas tank on the truck is infinit

11条回答
  •  鱼传尺愫
    2020-12-13 07:55

    static int findIndex(int A[], int B[]) {
        int N = A.length;
        int start=0;
        boolean isBreak=false;
        int total = 0;
        do {
            for(int i=start;i

提交回复
热议问题