Compare commits
No commits in common. "d4b56a88fd7961b9b261789f94d7396bbc4232aa" and "610d05ddb22a7cde876bcd51a31a0bf52f5ce68a" have entirely different histories.
d4b56a88fd
...
610d05ddb2
@ -1,7 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "minimum_number_of_operations_to_move_all_balls_to_each_box"
|
||||
version = "0.1.0"
|
@ -1,6 +0,0 @@
|
||||
[package]
|
||||
name = "minimum_number_of_operations_to_move_all_balls_to_each_box"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
@ -1,33 +0,0 @@
|
||||
pub struct Solution;
|
||||
|
||||
impl Solution {
|
||||
pub fn min_operations(boxes: String) -> Vec<i32> {
|
||||
let boxes: Vec<i32> = boxes.chars().map(|c| c as i32 - 48).collect();
|
||||
|
||||
let mut balls_counted_from_left = vec![0; boxes.len()];
|
||||
for i in 1..boxes.len() {
|
||||
balls_counted_from_left[i] = balls_counted_from_left[i - 1] + boxes[i - 1];
|
||||
}
|
||||
|
||||
let mut balls_counted_from_right = vec![0; boxes.len()];
|
||||
for i in (0..(boxes.len() - 1)).rev() {
|
||||
balls_counted_from_right[i] = balls_counted_from_right[i + 1] + boxes[i + 1];
|
||||
}
|
||||
|
||||
let mut steps_moving_to_right = vec![0; boxes.len()];
|
||||
for i in 1..boxes.len() {
|
||||
steps_moving_to_right[i] = steps_moving_to_right[i - 1] + balls_counted_from_left[i];
|
||||
}
|
||||
|
||||
let mut steps_moving_to_left = vec![0; boxes.len()];
|
||||
for i in (0..(boxes.len() - 1)).rev() {
|
||||
steps_moving_to_left[i] = steps_moving_to_left[i + 1] + balls_counted_from_right[i];
|
||||
}
|
||||
|
||||
steps_moving_to_left
|
||||
.iter()
|
||||
.zip(steps_moving_to_right.iter())
|
||||
.map(|(&l, &r)| l + r)
|
||||
.collect()
|
||||
}
|
||||
}
|
7
2469_convert_the_temperature/Cargo.lock
generated
7
2469_convert_the_temperature/Cargo.lock
generated
@ -1,7 +0,0 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "convert_the_temperature"
|
||||
version = "0.1.0"
|
@ -1,6 +0,0 @@
|
||||
[package]
|
||||
name = "convert_the_temperature"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
@ -1,7 +0,0 @@
|
||||
pub struct Solution;
|
||||
|
||||
impl Solution {
|
||||
pub fn convert_temperature(celsius: f64) -> Vec<f64> {
|
||||
vec![celsius + 273.15, celsius * 1.8 + 32.0]
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user