Software Engineer • Mid-Level
Software Engineer • Mid-Level
High QualityPrep Other Coding Questions Asked by Instacart
Continue with targeted prep from Instacart's coding question bank.
Interview Summary
I recently completed an Instacart Software Engineer virtual onsite covering coding, system design, and behavioral questions. The coding exercises involved resolving variable expressions with dependencies and error handling, as well as implementing shopping cart calculations with multiple discount rules. The system design discussion focused on inventory reservation, concurrency, and preventing overselling. I had spent most of my preparation time on system design, but the coding rounds ended up taking longer than expected.
Interview Details
Round 1: Coding— Variable Assignment and Expression Evaluation
The first coding problem involved evaluating variables defined through a collection of assignment statements. The interviewer gradually introduced more complicated requirements, starting with simple variable references and eventually adding arithmetic operations and invalid dependency handling.
-
Part 1 — Resolve Variable Dependencies
You are given an array of strings
arr. The first element contains the name of the target variable whose value must be determined. Each remaining element represents an assignment in the format:variable = expression. Initially, the right-hand side of an assignment can be either:- An integer constant.
- Another variable name.
Variables may reference other variables through a chain of assignments. The task is to resolve the target variable and return its final integer value as a string. For the initial version, all assignments are valid, each variable is assigned exactly once, and there are no circular dependencies or undefined references.
-
Example 1 — Direct Variable Reference
Input: arr = ["RESULT", "BASE = 13", "RESULT = BASE"] Output: "13" Explanation: RESULT references BASE, which has the value 13.Input: arr = ["RESULT", "BASE = 13", "RESULT = BASE"] Output: "13" Explanation: RESULT references BASE, which has the value 13. -
Example 2 — Negative Integer
Input: arr = ["TOTAL", "TOTAL = -24"] Output: "-24" Explanation: TOTAL is directly assigned the integer -24.Input: arr = ["TOTAL", "TOTAL = -24"] Output: "-24" Explanation: TOTAL is directly assigned the integer -24. -
Example 3 — Multiple Dependencies
Input: arr = [ "FINAL", "START = 8", "MIDDLE = START", "FINAL = MIDDLE" ] Output: "8" Explanation: FINAL references MIDDLE, which references START. The final value is 8.Input: arr = [ "FINAL", "START = 8", "MIDDLE = START", "FINAL = MIDDLE" ] Output: "8" Explanation: FINAL references MIDDLE, which references START. The final value is 8.
undefined -
Part 2 — Support Arithmetic Expressions
The interviewer extended
Unlock Full Details
Create a free account to unlock this interview experience report.