Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Pointer Scenarios and Outputs

HardPython00:00
Practice interviewer
In session
5 left
00:00

Your question is Pointer Scenarios and Outputs. Start with the requirements on the right.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.

Problem

Explain what the output would be for pointer-related code in different scenarios.

Represent each scenario with initially allocated pointer names and ordered operations. Support alias, rebind, write, increment, and read; aliases share storage, while rebinding changes only the pointer. Return the values produced by all read operations in order for each scenario.

Function signature: def pointer_outputs(scenarios): Input is a list of scenario dictionaries. Each has initial, a name-to-integer mapping, and operations, a list of operation strings. Output is a list of read-value lists.

Constraints

  • 1 <= number of scenarios <= 1000
  • 1 <= number of initial pointers per scenario <= 1000
  • 1 <= number of operations per scenario <= 1000
  • Pointer names contain no whitespace
  • Every referenced pointer name already exists when an operation executes
  • Values and write operands are integers

Function Signature

def pointer_outputs(scenarios):
Your solutionPython 3
You need to log in / sign up to run or submit.
Run your code to see test output