From d9e2d61db7b3ec268c5dbec117e1107d426e56d5 Mon Sep 17 00:00:00 2001 From: Vedeesh Dwivedi Date: Tue, 21 Oct 2025 12:27:00 +0530 Subject: [PATCH] Add LC_finvalvarafterop class for operation evaluation --- .../LC_finvalvarafterop.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/test/java/LeetCode/Final_Value_of_Variable_After_Performing_Operations/LC_finvalvarafterop.java diff --git a/src/test/java/LeetCode/Final_Value_of_Variable_After_Performing_Operations/LC_finvalvarafterop.java b/src/test/java/LeetCode/Final_Value_of_Variable_After_Performing_Operations/LC_finvalvarafterop.java new file mode 100644 index 00000000..48d20fd2 --- /dev/null +++ b/src/test/java/LeetCode/Final_Value_of_Variable_After_Performing_Operations/LC_finvalvarafterop.java @@ -0,0 +1,14 @@ +class LC_finvalvarafterop { + + public int finalValueAfterOperations(String[] operations) { + int x = 0; + for (String op : operations) { + if ("X++".equals(op) || "++X".equals(op)) { + x++; + } else { + x--; + } + } + return x; + } +}