From a96b65cbfad7f62f3db6b2eab105e4e25c0414c5 Mon Sep 17 00:00:00 2001 From: Jack Sangdahl Date: Fri, 27 Jun 2025 12:23:02 -0600 Subject: chore: remove old cpp and rust solutions --- other/eval_reverse_polish_notation.cpp | 46 ---------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 other/eval_reverse_polish_notation.cpp (limited to 'other/eval_reverse_polish_notation.cpp') diff --git a/other/eval_reverse_polish_notation.cpp b/other/eval_reverse_polish_notation.cpp deleted file mode 100644 index 4cd39b8..0000000 --- a/other/eval_reverse_polish_notation.cpp +++ /dev/null @@ -1,46 +0,0 @@ -#include "leetcode.h" - -class Solution { -public: - int evalRPN(vector &tokens) { - unordered_map> umf = { - {"+", [](long a, long b) { return a + b; }}, - {"-", [](long a, long b) { return a - b; }}, - {"*", [](long a, long b) { return a * b; }}, - {"/", [](long a, long b) { return a / b; }}}; - stack stk; - for (string &s : tokens) { - if (!umf.count(s)) - stk.push(stoi(s)); - else { - long op1 = stk.top(); - stk.pop(); - long op2 = stk.top(); - stk.pop(); - stk.push(umf[s](op2, op1)); - } - } - return static_cast(stk.top()); - } -}; - -int main() { - Solution obj; - vector tokens1 = {"2", "1", "+", "3", "*"}; - // output: 9 - // ((2 + 1) * 3) - cout << obj.evalRPN(tokens1); - vector tokens2 = {"4", "13", "5", "/", "+"}; - // output: 6 - // (4 + (13 / 5)) - cout << obj.evalRPN(tokens2); - vector tokens3 = {"10", "6", "9", "3", "+", "-11", "*", - "/", "*", "17", "+", "5", "+"}; - // output: 22 - // ((10 * (6 / (12 * -11))) + 17) + 5 - // ((10 * (6 / -132)) + 17) + 5 - // ((10 * 0) + 17) + 5 - // (0 + 17) + 5 - // 17 + 5 - cout << obj.evalRPN(tokens3); -} -- cgit v1.2.3