aboutsummaryrefslogtreecommitdiff
path: root/other/max_bags_rocks.rs
diff options
context:
space:
mode:
Diffstat (limited to 'other/max_bags_rocks.rs')
-rw-r--r--other/max_bags_rocks.rs20
1 files changed, 0 insertions, 20 deletions
diff --git a/other/max_bags_rocks.rs b/other/max_bags_rocks.rs
deleted file mode 100644
index 808c393..0000000
--- a/other/max_bags_rocks.rs
+++ /dev/null
@@ -1,20 +0,0 @@
-struct Solution;
-
-impl Solution {
- pub fn maximum_bags(capacity: Vec<i32>, rocks: Vec<i32>, mut additional_rocks: i32) -> i32 {
- let mut bag_space = (0..rocks.len()).map(|i| capacity[i] - rocks[i])
- .filter(|&d| d > 0)
- .collect::<Vec<_>>();
- let bag_full = rocks.len() - bag_space.len();
- bag_space.sort_unstable();
- bag_space.into_iter()
- .take_while(|&n| { additional_rocks -= n; additional_rocks >= 0 })
- .count() as i32 + bag_full as i32
- }
-}
-
-fn main() {
- let capacity = vec![2,3,4,5];
- let rocks = vec![1,2,4,4];
- print!("{}", Solution::maximum_bags(capacity, rocks, 2)); //expect: 3
-}