Back to problems

String-Command Calculator

Algorithm · Snowflake · Medium

Requirements Accept a sequence of commands, where each command is represented as a string containing an operator and an operand, such as "ADD 6", "SUB 3", "MULT 4", or "DIV 2". Track one accumulator while processing the commands in their given order. It begins at 0; for a sequence consisting only of multiplicative operations, confirm with the interviewer whether the initial value should instead be 1. After applying every command, record or return the accumulator's new value.…

Checking your access…