FastPrep2048 Move Simulator
Problems/2048 Move Simulator

2048 Move Simulator

Benchling logoBenchling● MediumNEW GRADOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Benchling new grad online assessment. We follow the exercise in the report. The report leaves out some input limits and some interface details. We chose those. Our version is about 95% the same as the reported question.

Given a square 2048 grid and a string moves, apply the moves in order and return the final grid. L, R, U and D move tiles left, right, up and down.

Each move slides all nonzero tiles toward the side the move names and merges each adjacent pair of equal tiles once. Do not spawn new tiles.

Function

simulate2048(grid: int[][], moves: String) → int[][]

Examples

Example 1

grid = [[2,0,2,2],[0,0,0,0],[0,0,0,0],[0,0,0,0]]moves = "L"return = [[4,2,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]]
grid
012302022100002000030000
→
return
012304200100002000030000
Moved or new

In the top row, the first two equal tiles from the left merge, and the third tile slides in next to the result.

Constraints

  • 2 <= grid.length <= 20 and the grid is square.
  • Every entry is zero or a positive power of two.
  • moves contains only L, R, U, and D.
  • The sum of all starting tile values is at most 2147483647. Moves keep this sum the same because no tiles spawn.

More Benchling interview questions

  • Minimum Genetic MutationOA · Seen Feb 2019
  • Validate Nested JSON Against a SchemaONSITE INTERVIEW · Seen Dec 2025
  • Bounded HTTP Retry FlowPHONE SCREEN · Seen Nov 2025
  • Future-Aware Cache EvictionPHONE SCREEN · Seen Aug 2025
  • Generate All Contiguous Protein ChainsPHONE SCREEN · Seen Jul 2024
  • Degenerate DNA Substring SearchONSITE INTERVIEW · Seen Jun 2024
  • Eight-Direction Keyboard Typing TimePHONE SCREEN · Seen Apr 2022
  • Generate Proteins from Contiguous Named SequencesPHONE SCREEN · Seen Aug 2021
  • Longest Substring Without Repeating CharactersONSITE INTERVIEW · Seen Jul 2021
  • Next Palindrome NumberPHONE SCREEN · Seen Jul 2021

Similar questions at other companies

  • Maximum Diamond SumHudson River Trading · OAHudson River Trading interview questions
  • Robot Navigation Around LasersRoblox · OARoblox interview questions
  • Apply a Reversi MoveAmazon · OA
  • Flip, Invert, and Smooth a Binary ImageAbridge · OAAbridge interview questions
  • First Completed Mingo LineEpic · OAEpic interview questions
  • Rotate a Square Matrix ClockwiseVisa · OAVisa interview questions
  • Sort Concentric Matrix Borders ClockwiseByteDance · OAByteDance interview questions
  • Sparse Valid Conv2D From ScratchNVIDIA · OANVIDIA interview questions
  • Apply Matrix OperationsCapital One · OACapital One interview questions
  • Rotate the Box and Drop the StonesZipRecruiter · OAZipRecruiter interview questions
All Benchling interview questionsSee Benchling hiring insights
Saved
class Solution {
    public int[][] simulate2048(int[][] grid, String moves) {
        // Write your code here.
    }
}
Checking account…