Algorithms and Data Structures/Coding Practices

AlgoExpert Minimum Waiting Time

brightlightkim 2022. 7. 12. 15:51

import java.util.*;

class Program {

  public int minimumWaitingTime(int[] queries) {
    Arrays.sort(queries);
    int totalSum = 0;
    int sum = 0;
    for (int i = 1; i < queries.length; i++){
      sum += queries[i - 1];
      totalSum += sum;
    }
    return totalSum;
  }
}

'Algorithms and Data Structures > Coding Practices' 카테고리의 다른 글

LeetCode 74. Search a 2D Matrix  (0) 2022.07.13
AlgoExpert Class Photos  (0) 2022.07.13
AlgoExpert Depth First Search (DFS)  (0) 2022.07.12
AlgoExpert Node Depths  (0) 2022.07.12
AlgoExpert Sorted Squared Array  (0) 2022.07.10