diff options
author | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
---|---|---|
committer | Jack Sangdahl <[email protected]> | 2025-06-27 12:23:02 -0600 |
commit | a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 (patch) | |
tree | e2a2b3f49f9fb741be81415266ac93e74cff42ec /other/eval_reverse_polish_notation.rs | |
parent | 694ad5ed71edcb1deccab54b72d706b779918276 (diff) | |
download | leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.tar.gz leetcode-a96b65cbfad7f62f3db6b2eab105e4e25c0414c5.zip |
chore: remove old cpp and rust solutions
Diffstat (limited to 'other/eval_reverse_polish_notation.rs')
-rw-r--r-- | other/eval_reverse_polish_notation.rs | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/other/eval_reverse_polish_notation.rs b/other/eval_reverse_polish_notation.rs deleted file mode 100644 index 11a36e3..0000000 --- a/other/eval_reverse_polish_notation.rs +++ /dev/null @@ -1,29 +0,0 @@ -struct Solution; - -impl Solution { - pub fn eval_rpn(tokens: Vec<String>) -> i32 { - tokens.iter().fold(Vec::new(), |mut stack, x| { - if let Ok(x) = x.parse() { - stack.push(x); - } else if let (Some(rhs), Some(lhs)) = (stack.pop(), stack.pop()) { - stack.push(match x.as_str() { - "+" => lhs + rhs, - "-" => lhs - rhs, - "*" => lhs * rhs, - "/" => lhs / rhs, - _ => unreachable!() - }) - } - stack - }) [0] - } -} - -fn main() { - let tokens1 = ["2","1","+","3","*"]; - let tokens2 = ["4","13","5","/","+"]; - let tokens3 = ["10","6","9","3","+","-11","*","/","*","17","+","5","+"]; - println!("{}", Solution::eval_rpn(tokens1)); - println!("{}", Solution::eval_rpn(tokens2)); - println!("{}", Solution::eval_rpn(tokens3)); -} |