ENTRI Hiring | Online Assessment Question | On-Campus (2023)
Question · Posted Jun 2026
Problem: Final Value of Variable After Performing Operations Given an array operations containing strings "++X", "X++", "--X", and "X--", a variable X starts at 0. "++X" or "X++" increases X by 1. "--X" or "X--" decreases X by 1. Return the final value of X after performing all operations. Example Input operations = ["--X","X++","X++"] Output 1 Explanation Start with X = 0 "--X" → X = -1 "X++" → X = 0 "X++" → X = 1 Final value = ...
The full answer & interview discussion are available to premium members.
Log in Create a free account