feat: 2011_final_value_of_variable_after_performing_operations
This commit is contained in:
parent
66d8753334
commit
f06e82f965
7
2011_final_value_of_variable_after_performing_operations/Cargo.lock
generated
Normal file
7
2011_final_value_of_variable_after_performing_operations/Cargo.lock
generated
Normal file
@ -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"
|
@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "final_value_of_variable_after_performing_operations"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
@ -0,0 +1,17 @@
|
|||||||
|
pub struct Solution;
|
||||||
|
|
||||||
|
impl Solution {
|
||||||
|
pub fn final_value_after_operations(operations: Vec<String>) -> i32 {
|
||||||
|
let mut result = 0;
|
||||||
|
|
||||||
|
for op in operations {
|
||||||
|
if op.contains('+') {
|
||||||
|
result += 1;
|
||||||
|
} else {
|
||||||
|
result -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user