aboutsummaryrefslogtreecommitdiff
path: root/other/earliest_possible_full_bloom.rs
diff options
context:
space:
mode:
authorJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
committerJack Sangdahl <[email protected]>2025-03-10 00:36:13 -0600
commit7c60dee83b436e8e8a667bf9f191beced8de4fc3 (patch)
treeeb7a24ee2067f92245c57bb118e85a1baf15df50 /other/earliest_possible_full_bloom.rs
parent5d7cdc215e4ba1ec4cbb24c084cccb5e5e641468 (diff)
downloadleetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.tar.gz
leetcode-7c60dee83b436e8e8a667bf9f191beced8de4fc3.zip
chore: move cpp and rust code to directory
Diffstat (limited to 'other/earliest_possible_full_bloom.rs')
-rw-r--r--other/earliest_possible_full_bloom.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/other/earliest_possible_full_bloom.rs b/other/earliest_possible_full_bloom.rs
new file mode 100644
index 0000000..b8e6444
--- /dev/null
+++ b/other/earliest_possible_full_bloom.rs
@@ -0,0 +1,20 @@
+struct Solution;
+
+impl Solution {
+ pub fn earliest_full_bloom(plant_time: Vec<i32>, grow_time: Vec<i32>) -> i32 {
+ let n = plant_time.len();
+ let mut plant_data: Vec<(i32, i32)> = plant_time.into_iter().zip(grow_time.into_iter()).collect();
+ plant_data.sort_by(|a,b| b.1.cmp(&a.1));
+ let (mut free_time, mut max_bloom_time) = (0,0);
+ for i in 0..n {
+ free_time += plant_data[i].0;
+ max_bloom_time = max_bloom_time.max(free_time + plant_data[i].1);
+ }
+ max_bloom_time
+ }
+}
+
+fn main() {
+ let (plant_time, grow_time) = (vec![1,4,3], vec![2,3,1]);
+ print!("{}", Solution::earliest_full_bloom(plant_time, grow_time));
+}