1094. Car Pooling Medium
1/**
2 * [1094] Car Pooling
3 *
4 * There is a car with capacity empty seats. The vehicle only drives east (i.e., it cannot turn around and drive west).
5 * You are given the integer capacity and an array trips where trips[i] = [numPassengersi, fromi, toi] indicates that the i^th trip has numPassengersi passengers and the locations to pick them up and drop them off are fromi and toi respectively. The locations are given as the number of kilometers due east from the car's initial location.
6 * Return true if it is possible to pick up and drop off all passengers for all the given trips, or false otherwise.
7 *
8 * Example 1:
9 *
10 * Input: trips = [[2,1,5],[3,3,7]], capacity = 4
11 * Output: false
12 *
13 * Example 2:
14 *
15 * Input: trips = [[2,1,5],[3,3,7]], capacity = 5
16 * Output: true
17 *
18 *
19 * Constraints:
20 *
21 * 1 <= trips.length <= 1000
22 * trips[i].length == 3
23 * 1 <= numPassengersi <= 100
24 * 0 <= fromi < toi <= 1000
25 * 1 <= capacity <= 10^5
26 *
27 */
28pub struct Solution {}
29
30// problem: https://leetcode.com/problems/car-pooling/
31// discuss: https://leetcode.com/problems/car-pooling/discuss/?currentPage=1&orderBy=most_votes&query=
32
33// submission codes start here
34
35impl Solution {
36 pub fn car_pooling(trips: Vec<Vec<i32>>, capacity: i32) -> bool {
37 false
38 }
39}
40
41// submission codes end
42
43#[cfg(test)]
44mod tests {
45 use super::*;
46
47 #[test]
48 fn test_1094() {
49 }
50}
51
Back
© 2025 bowen.ge All Rights Reserved.