FastPrepEvaluate Sequential Variable Assignments

Evaluate Sequential Variable Assignments

Google logoGoogle● HardINTERNONSITE INTERVIEW

Problem statement

Process assignments in order. Assignment i evaluates expressions[i] using the current variable values, then stores the result in the variable names[i]. Return the value produced by each assignment.

An expression contains nonnegative decimal integer literals, lowercase variable names, optional unary + or - before an operand, and binary +, -, *, and /. Spaces may appear between tokens. Parentheses are absent.

The problem statement continues
Pro

Examples

Example 1

names = ["a","b","c"]expressions = ["2 + 3 * 4","a / 3","b * -2 + a"]return = [14,4,6]

a is 14, b is 14 / 3 = 4, and c is 4 * -2 + 14 = 6.

FastPrep Pro
Reported in 1 Google interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
See Google hiring insights
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Google interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 2 more worked examples, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week