757. 设置交集大小至少为2

This commit is contained in:
li-chx 2025-11-20 21:57:12 +08:00
parent 30e2df43c4
commit 67d79e3553
1 changed files with 5 additions and 10 deletions

View File

@ -1,15 +1,15 @@
mod arr;
struct Solution;
impl Solution {
pub fn find_minimum_time(tasks: Vec<Vec<i32>>) -> i32 {
let mut tasks = tasks;
pub fn intersection_size_two(intervals: Vec<Vec<i32>>) -> i32 {
let mut tasks = intervals;
tasks.sort_by_key(|task| task[1]);
let mut stack:Vec<Vec<i32>> = Vec::new();
stack.push(vec![-2,-2,0]);
for task in tasks.iter() {
let start = task[0];
let end = task[1];
let mut d = task[2];
let mut d = 2;
let pos = stack.partition_point(|x| x[0] < start) - 1;
d -= stack[stack.len() - 1][2] - stack[pos][2];
if start <= stack[pos][1] {
@ -27,13 +27,8 @@ impl Solution {
stack[stack.len() - 1][2]
}
}
/*
https://leetcode.cn/problems/minimum-time-to-complete-all-tasks/solutions/2163130/tan-xin-pythonjavacgo-by-endlesscheng-w3k3/
*/
fn main() {
let result = Solution::find_minimum_time(arr::make_matrix("[[1,3,2],[2,5,3],[5,6,2]]"));
let result = Solution::intersection_size_two(arr::make_matrix("[[1,3],[3,7],[8,9]]"));
println!("{:?}", result);
}