프로그래머스 다리를 지나는 트럭 - java


프로그래머스 다리를 지나는 트럭 - java

import java.util.*; class Solution { public int solution(int bridge_length, int weight, int[] truck_weights) { int answer = 0; int queueIdx = 0; int timer = 0; int truckWeightsTotalOnBridge = 0; // Integer [truck weight][on bridge time][off bridge time] LinkedList<Integer[]> trucksOnBridge = new LinkedList<>(); int trucksOffBridgeCount = 0; // 트럭이 다 지날 때까지 loop while (trucksOffBridgeCount < truck_weights.length) { timer++; // 다리에 올라와 있는 트럭 중 선두에 있는 트럭이 다리를 다 지나갔다 // trucksOnBridge queue에서 제거하고 t...



원문링크 : 프로그래머스 다리를 지나는 트럭 - java