FastPrepString Copy and Move Lifecycle
Problems/String Copy and Move Lifecycle

String Copy and Move Lifecycle

Squarepoint Capital logoSquarepoint Capital● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Squarepoint Capital new-grad phone screen. The report asks for a String class with copy and move construction and assignment. Our version uses a finite list of operations. It adds append and read checks, empty values after a move, rules for self-assignment, and limits. Our version is about 70% the same as the reported class exercise.

Implement the value behavior of a String class with copy and move construction and assignment. Process commands in order, starting with no named objects.

For this exercise, assume these commands:

  • ["NEW", name, text] constructs a new object.
  • ["COPY", source, destination] copy-constructs a new destination with independent character storage.
  • ["MOVE", source, destination] move-constructs a new destination and makes the source empty.
  • ["COPY_ASSIGN", destination, source] replaces an existing destination with an independent copy.
  • ["MOVE_ASSIGN", destination, source] replaces an existing destination by moving the source value, then makes the source empty.
  • ["APPEND", name, suffix] appends characters to one object.
  • ["GET", name] records its current text.

Return the recorded texts in order. Both forms of self-assignment leave the object unchanged. A moved-from object remains usable as an empty string. Appending to one copy must not change another.

Function

simulateStringValues(commands: String[][]) → String[]

Examples

Example 1

commands = [["NEW","a","ab"],["COPY","a","b"],["APPEND","a","c"],["GET","a"],["GET","b"]]return = ["abc","ab"]

The copy starts with ab. Appending to a changes it to abc while b stays ab.

Example 2

commands = [["NEW","a","cat"],["MOVE","a","b"],["GET","a"],["GET","b"],["APPEND","a","x"],["GET","a"],["GET","b"]]return = ["","cat","x","cat"]

Moving transfers cat into b and empties a. Reusing the empty source with an append produces x without changing b.

Example 3

commands = [["NEW","a","a"],["NEW","b","b"],["COPY_ASSIGN","a","b"],["MOVE_ASSIGN","b","a"],["GET","a"],["GET","b"]]return = ["","b"]

Copy assignment first gives a the value b. Moving that value back into the existing b object empties a.

Constraints

  • 0 <= commands.length <= 200.
  • Each command has 2 or 3 tokens.
  • Every token has length at most 50.
  • Commands follow the listed shapes and reference valid existing objects. Constructor destinations are new names. Names match [a-z][a-z0-9]{0,11}; text and suffixes contain only lowercase English letters and may be empty.
  • No object text exceeds 5000 characters, and all returned text contains at most 30000 characters in total.

More Squarepoint Capital Phone Screen questions

  • Newton Square Root to a Guaranteed TolerancePHONE SCREEN · Seen Nov 2026
  • Probability of Consecutive HeadsPHONE SCREEN · Seen Nov 2026
  • Three Points in a Semicircle: Monte Carlo EstimatePHONE SCREEN · Seen Nov 2026
  • Combine Two Index SequencesPHONE SCREEN · Seen Aug 2026
  • Parse, Normalize, and Combine PolynomialsPHONE SCREEN · Seen Aug 2026
  • Sorted Insertion SnapshotsPHONE SCREEN · Seen Aug 2026
  • Strong and Weak Reference LifecyclePHONE SCREEN · Seen Aug 2026
  • Target Sum Across Two Sorted ArraysPHONE SCREEN · Seen Aug 2026
  • Classify Heap Addresses from a Memory SnapshotPHONE SCREEN · Seen Nov 2025
  • Fixed Worker Pool with a Shared QueuePHONE SCREEN · Seen Nov 2025

Similar questions at other companies

  • In-Memory Filesystem CommandsPerplexity AI · PHONE SCREEN · ONSITE INTERVIEWPerplexity AI interview questions
  • File Storage ServiceCresta · PHONE SCREENCresta interview questions
  • Return Every Matching DecryptionDuolingo · PHONE SCREENDuolingo interview questions
  • Numeric Poker OperationsRippling · PHONE SCREENRippling interview questions
  • Reference-Counted Deduplicating File SystemCitadel · PHONE SCREENCitadel interview questions
  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • Design In-Memory File SystemSnowflake · PHONE SCREENSnowflake interview questions
  • In-Memory Vault File SystemHarvey · ONSITE INTERVIEWHarvey interview questions
  • Parcel Event TrackingAirbnb · OAAirbnb interview questions
  • Account Scheduler - Availability and AcquireStripe · ONSITE INTERVIEWStripe interview questions

Interview reports that mention this question

  • Squarepoint Capital C++ and Python SWE Interviews: 7 Experiences

Squarepoint Capital interview experiences

  • Squarepoint Campus SDE Interviews: 7 Experiences (Part 2 of 2)
  • Squarepoint Capital New Grad SDE OA: 5 Experiences (Part 1 of 2)
All Squarepoint Capital interview questionsSee Squarepoint Capital hiring insights
Saved
class Solution {
    public String[] simulateStringValues(String[][] commands) {
        // write your code here
    }
}
Checking account…