diff --git a/2011_final_value_of_variable_after_performing_operations/Cargo.lock b/2011_final_value_of_variable_after_performing_operations/Cargo.lock new file mode 100644 index 0000000..f1b8c94 --- /dev/null +++ b/2011_final_value_of_variable_after_performing_operations/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "final_value_of_variable_after_performing_operations" +version = "0.1.0" diff --git a/2011_final_value_of_variable_after_performing_operations/Cargo.toml b/2011_final_value_of_variable_after_performing_operations/Cargo.toml new file mode 100644 index 0000000..60df196 --- /dev/null +++ b/2011_final_value_of_variable_after_performing_operations/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "final_value_of_variable_after_performing_operations" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/2011_final_value_of_variable_after_performing_operations/src/lib.rs b/2011_final_value_of_variable_after_performing_operations/src/lib.rs new file mode 100644 index 0000000..f94c89f --- /dev/null +++ b/2011_final_value_of_variable_after_performing_operations/src/lib.rs @@ -0,0 +1,17 @@ +pub struct Solution; + +impl Solution { + pub fn final_value_after_operations(operations: Vec) -> i32 { + let mut result = 0; + + for op in operations { + if op.contains('+') { + result += 1; + } else { + result -= 1; + } + } + + result + } +}