Skip to content

Latest commit

 

History

History
20 lines (16 loc) · 476 Bytes

File metadata and controls

20 lines (16 loc) · 476 Bytes

LeetCode Records - Question 2011 Final Value of Variable After Performing Operations

Attempt 1: Check the 2nd character

class Solution {
    public int finalValueAfterOperations(String[] operations) {
        int sum = 0;

        for (String operation : operations) {
            sum += operation.charAt(1) == '+' ? 1 : -1;
        }

        return sum;
    }
}
  • Runtime: 0 ms (Beats: 100.00%)
  • Memory: 42.57 MB (Beats: 49.08%)