Trace Pointer Rebinding and Pointee Updates
Updated
Problem statement
A function receives a pointer to a caller-owned integer by value. Process each operation in order:
WRITE:xwritesxthrough the function's current pointer.REBIND:xchanges only the function's local pointer copy so it points to a local integer whose value isx.
Once rebound, later writes affect the local integer rather than the caller-owned integer. Return the caller-owned value after the function returns.
Function
callerValueAfter(initialValue: int, operations: String[]) → intExamples
Example 1
initialValue = 10operations = ["REBIND:100"]return = 10Rebinding changes only the local pointer copy, so the caller still observes 10.
Example 2
initialValue = 10operations = ["WRITE:100"]return = 100Writing through the original pointer updates the caller-owned integer.
Constraints
-1000000000 <= initialValue <= 1000000000.0 <= operations.length <= 100000.- Every operation is
WRITE:xorREBIND:x, wherexis a signed 32-bit integer.
More Arista Networks interview questions
- First Missing Number in a Consecutive ArrayOA · PHONE SCREEN · Seen Oct 2026
- Remove All Repeated Values from a Linked ListPHONE SCREEN · Seen Oct 2026
- Trace Nested Object Destruction OrderPHONE SCREEN · Seen Oct 2026
- Swap Adjacent NibblesPHONE SCREEN · Seen Aug 2026
- Unique Target-Sum Pairs in a Sorted Doubly Linked ListPHONE SCREEN · Seen Aug 2026
- Generic Stack Operation SequencePHONE SCREEN · Seen Aug 2026
- API Bandwidth AllocationOA · Seen Sep 2026
- LFU CacheOA · Seen Sep 2026
- Maximum Server Processing TimeOA · Seen Aug 2026
- Minimum Adjacent Merges to Form a PalindromeOA · Seen Aug 2026
Similar questions at other companies
- Search and Format ContactsAdyen · PHONE SCREENAdyen interview questions
- Subtract Two Large Number StringsStackAdapt · PHONE SCREENStackAdapt interview questions
- Portfolio Valuation, Part 1Stripe · PHONE SCREENStripe interview questions
- Format a Signed Integer with CommasHudson River Trading · PHONE SCREENHudson River Trading interview questions
- Fair Coin from a Biased CoinAnthropic · PHONE SCREENAnthropic interview questions
- Run-Length DecodingApple · PHONE SCREENApple interview questions
- Match a Variadic Function SignatureConfluent · PHONE SCREENConfluent interview questions
- Decode and Store StringsAirbnb · PHONE SCREENAirbnb interview questions
- Delimiter-Parsing String Iteratoramo · PHONE SCREEN
- SimpleRDD Word CountDatologyAI · PHONE SCREEN