simulation
simulation is one of the most repeated interview dimensions. Start with edge-safe fundamentals, then move into pattern-level trade-offs.
Interview Signal
Frequently tests problem modeling, edge handling, and verbal clarity.
Common Pitfall
Template-only answers break under follow-up questioning.
Practice Strategy
Practice in 3-5 problem rounds and always review complexity alternatives.
Recommended Progression
Foundation
Pattern Bridge
High-Pressure Round
Multiply Strings
Multiply Strings requires simulating integer multiplication using only string operations without direct numeric conversi…
Spiral Matrix
Given an m x n matrix, return all elements in spiral order starting from the top-left corner.
Spiral Matrix II
Generate a spiral matrix of size n x n, filled with elements from 1 to n² in spiral order, for interview-focused solving…
Add Binary
Add Binary involves summing two binary strings and returning the result as a binary string using math and string manipul…
Text Justification
Text Justification requires packing words into lines to match a specified width, ensuring even distribution of spaces.
Add Digits
Add Digits involves repeatedly summing digits of a number until a single digit is obtained.
Game of Life
Solve the Game of Life by updating each cell based on its eight neighbors using Array and Matrix simulation patterns eff…
Fizz Buzz
Generate a list from 1 to n replacing multiples of 3 with Fizz, 5 with Buzz, and both with FizzBuzz efficiently.
Add Strings
Given two non-negative integers as strings, sum them and return the result as a string without converting to integers di…
Teemo Attacking
Compute the total poisoned time Ashe experiences from Teemo's attacks using an array-based simulation approach efficient…
Diagonal Traverse
Traverse a matrix diagonally and return all elements in the specific zig-zag order required by the problem pattern.
Complex Number Multiplication
This problem requires multiplying two complex numbers, given in string form, and returning the result in the same format…
Reshape the Matrix
Reshape the Matrix involves transforming a 2D matrix into a new matrix with the same elements in row-major order, follow…
Fraction Addition and Subtraction
Solve fraction addition and subtraction by handling expressions, calculating results, and simplifying fractions to irred…
Solve the Equation
Solve the equation for the variable 'x' and determine its value or state if there is no solution or infinite solutions.
Robot Return to Origin
Judge whether a robot returns to the origin after a sequence of moves using string manipulation and simulation.
Baseball Game
Simulate baseball score operations using a stack-based approach to compute the final score after all operations.
Asteroid Collision
Determine the final positions of moving asteroids using a stack-based simulation for efficient collision resolution in l…
Contain Virus
Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…
Flipping an Image
Flip each row of a binary matrix horizontally and invert its values efficiently using a two-pointer scanning approach.
Backspace String Compare
Compare two strings after processing backspaces using efficient two-pointer scanning and careful invariant tracking to e…
Transpose Matrix
Transpose Matrix problem requires flipping a matrix's rows and columns to return the transposed version.
Walking Robot Simulation
The Walking Robot Simulation problem involves moving a robot in an infinite grid and calculating its furthest distance f…
Spiral Matrix III
Solve the Spiral Matrix III problem by simulating the movement across a matrix with specific constraints on direction an…
Validate Stack Sequences
Determine if a sequence of push and pop operations can produce the given popped array using a stack-based state approach…
Reveal Cards In Increasing Order
Determine the initial deck order to reveal cards in strictly increasing order using queue-driven simulation logic.
Sum of Even Numbers After Queries
Efficiently update an integer array based on queries and compute the sum of even numbers after each modification using s…
Available Captures for Rook
This problem involves finding the number of pawns a rook can capture on a chessboard, considering obstacles like bishops…
Clumsy Factorial
Compute the clumsy factorial of a number using a fixed rotation of multiply, divide, add, and subtract operations effici…
Robot Bounded In Circle
Determine if a robot following a repeated instruction sequence stays within a bounded circle using math and string simul…
Car Pooling
Determine if a car can handle multiple trips without exceeding its capacity using array sorting and event simulation tec…
Distribute Candies to People
Distribute candies to people in a way that follows a mathematical pattern, ensuring the distribution is correct.
Queens That Can Attack the King
Identify all black queens on an 8x8 chessboard that can attack the white king using array and matrix simulation techniqu…
Cells with Odd Values in a Matrix
This problem involves updating a matrix based on given indices and counting cells with odd values afterward.
Shift 2D Grid
Shift 2D Grid requires shifting elements of a matrix by a given number of times, simulating step-by-step movement.
Find Winner on a Tic Tac Toe Game
Determine the winner of a Tic Tac Toe game by scanning moves and using hash lookups for rows, columns, and diagonals eff…
Print Words Vertically
Transform a string into vertical columns by arranging each word character in array positions while trimming trailing spa…
Create Target Array in the Given Order
Learn how to efficiently create a target array by inserting elements at specified indices using array simulation techniq…
Number of Steps to Reduce a Number in Binary Representation to One
Determine the number of steps to reduce a binary representation of a number to 1 by following specific rules.
Queries on a Permutation With Key
This problem involves processing queries on a permutation using an array and binary indexed tree for efficient results.
Build an Array With Stack Operations
Simulate stack operations to match a target array while processing numbers from 1 to n.
Last Moment Before All Ants Fall Out of a Plank
This problem involves simulating ant movement on a plank to determine the last moment before all ants fall off.
Water Bottles
Maximize the number of water bottles you can drink by simulating the exchange process between full and empty bottles.
Find the Winner of an Array Game
Determine the integer that wins an array game by achieving k consecutive victories through simulated pairwise comparison…
Find Kth Bit in Nth Binary String
Determine the k-th bit in the n-th binary string using a recursive construction that inverts and reverses previous strin…
Most Visited Sector in a Circular Track
Determine which sectors on a circular track are visited most frequently using array and simulation techniques efficientl…
Find Latest Group of Size M
Determine the latest step where a contiguous group of ones of exact length m exists using array scanning and hash tracki…
Count Unhappy Friends
Determine the number of unhappy friends in paired arrangements using array-based simulation for preference violations.
Maximum Profit of Operating a Centennial Wheel
Maximize the profit from operating a Centennial Wheel by determining the optimal number of rotations based on customer a…
Design Parking System
Implement a class to manage a parking lot with fixed slots for big, medium, and small cars, tracking occupancy efficient…
Get Maximum in Generated Array
Compute the maximum value in a generated array using defined recurrence rules, leveraging array simulation techniques ef…
Concatenation of Consecutive Binary Numbers
Calculate the decimal value of concatenated binary numbers from 1 to n using efficient bit manipulation techniques.
Count of Matches in Tournament
Calculate the total matches in a tournament by simulating rounds and applying simple math rules for advancing teams.
Number of Students Unable to Eat Lunch
Simulate a queue of students with sandwich preferences and determine how many can't eat based on available sandwiches.
Average Waiting Time
Compute the average waiting time for customers using array traversal and simulation of a single chef processing orders s…
Where Will the Ball Fall
Determine where each ball exits a diagonal board grid or if it gets stuck, using matrix simulation with careful traversa…
Number of Orders in the Backlog
Determine the total number of unfulfilled buy and sell orders using heaps to simulate backlog processing efficiently in …
Minimum Number of Operations to Reinitialize a Permutation
Find the minimum number of operations to reinitialize a permutation of size n using specific operations.
Find the Winner of the Circular Game
Find the winner of a circular game by simulating the elimination process with a queue-driven approach.
Incremental Memory Leak
Solve Incremental Memory Leak by simulating each second carefully and using math to reason about the crash time bound.
Find the Student that Will Replace the Chalk
Identify the first student who will run out of chalk using a simulation with prefix sums and binary search.
Remove All Occurrences of a Substring
Remove all occurrences of a specified substring from a string using efficient stack-based state management.
Cyclically Rotating a Grid
This problem requires cyclically rotating a grid by rotating each layer of the matrix counter-clockwise for a specified …
Build Array from Permutation
The problem asks to build an array from a given permutation using an efficient approach.
Concatenation of Array
This problem asks you to create an array of double the size, where each element is repeated twice in sequence.
Sum of Digits of String After Convert
Convert a lowercase string into digits and repeatedly sum them k times using a direct string plus simulation approach.
Final Value of Variable After Performing Operations
Compute the final value of X by simulating each string operation in the array sequentially with careful tracking.
Convert 1D Array Into 2D Array
Convert a 1D integer array into a structured 2D array with specified rows and columns using all elements sequentially.
Find Missing Observations
Given a set of dice rolls, calculate the missing observations based on the mean and return them or determine if it's imp…
Simple Bank System
Design a simple bank system that processes transactions like withdrawals, deposits, and transfers while managing account…
Number of Valid Move Combinations On Chessboard
Given a set of pieces on a chessboard, calculate the number of valid move combinations without overlap using backtrackin…
Walking Robot Simulation II
The Walking Robot Simulation II problem challenges you to simulate robot movements and track its position and direction …
Time Needed to Buy Tickets
Calculate the total time for a specific person to buy all their tickets using queue-driven state processing.
Decode the Slanted Ciphertext
Decode the Slanted Ciphertext problem requires decoding a slanted cipher using string manipulation and simulation based …
Watering Plants
Simulate watering plants while managing a watering can's capacity, considering distance and refills.
Watering Plants II
Simulate watering a row of plants with Alice and Bob using two-pointer scanning, tracking refills precisely for each ste…
Adding Spaces to a String
Learn to efficiently insert spaces in a string using two-pointer scanning with invariant tracking in linear time.
Execution of All Suffix Instructions Staying in a Grid
Simulate robot moves from every instruction index on an n x n grid, counting valid steps without leaving boundaries.
Divide a String Into Groups of Size k
Divide a string into equal groups of size k, using a fill character to complete the last group if needed.
Rearrange Array Elements by Sign
Rearrange an array by alternating positive and negative integers using a two-pointer approach with invariant tracking.
Keep Multiplying Found Values by Two
The "Keep Multiplying Found Values by Two" problem involves repeatedly multiplying a number by two if it is found in an …
Partition Array According to Given Pivot
Rearrange an array around a pivot while maintaining relative order using a two-pointer scanning approach efficiently.
Count Operations to Obtain Zero
Simulate operations on two integers until one becomes zero, counting how many steps it takes to achieve the result.
Find Three Consecutive Integers That Sum to a Given Number
Given a number, find three consecutive integers that sum to it, or return an empty array if no such integers exist.
Count Integers With Even Digit Sum
Solve this Easy Math plus Simulation problem by counting numbers whose digit sums are even up to a given limit efficient…
Merge Nodes in Between Zeros
This problem requires merging nodes between zeros in a linked list by summing up the values between consecutive zeros.
Count Artifacts That Can Be Extracted
Count the number of artifacts that can be extracted after excavating specified grid cells.
Count Collisions on a Road
Count Collisions on a Road is a problem where you calculate the number of car collisions based on their movements in a s…
Find Triangular Sum of an Array
The problem asks for calculating the triangular sum of an array through repeated pairwise summation.
Calculate Digit Sum of a String
Learn how to repeatedly sum digit groups in a string until its length is at most k using string simulation techniques.
Count Unguarded Cells in the Grid
Solve Count Unguarded Cells in the Grid by marking guard sight lines across a blocked matrix and counting untouched empt…
Min Max Game
The Min Max Game problem requires simulating an array reduction process to find the last remaining number.
Replace Elements in an Array
Replace Elements in an Array involves applying a series of operations to replace values in an array with new ones based …
Design a Text Editor
Design a text editor that supports text manipulation and cursor navigation operations efficiently with linked-list-based…
Calculate Amount Paid in Taxes
Calculate the total tax owed by iterating through sorted brackets and applying each rate incrementally to your income.
Spiral Matrix IV
In this problem, you need to generate a matrix filled with values from a linked list in a spiral order.
Number of People Aware of a Secret
Calculate how many people know a secret over n days using state transition dynamic programming and careful simulation of…
Equal Row and Column Pairs
Identify all pairs of rows and columns in a square matrix that contain identical elements in the same sequence efficient…
Make Array Zero by Subtracting Equal Amounts
Minimize operations to make all array elements zero by subtracting equal amounts in each operation.
Task Scheduler II
Complete tasks in the optimal number of days by considering breaks and task type constraints.
Time Needed to Rearrange a Binary String
Calculate the exact seconds required to convert all 01 pairs into 10 in a binary string using state transitions.
Removing Stars From a String
Remove all stars from a string by simulating the removal process using a stack to manage characters and stars efficientl…
Meeting Rooms III
Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.
Apply Operations to an Array
Transform an array by applying adjacent doubling operations and shifting zeros efficiently using two-pointer scanning te…
Total Cost to Hire K Workers
Optimize the total cost of hiring exactly k workers using a two-pointer approach with invariant tracking and priority qu…
Difference Between Ones and Zeros in Row and Column
This problem requires computing a difference matrix based on the ones and zeros in each row and column of a binary matri…
Delete Greatest Value in Each Row
Calculate the total of removed maximum values from each row of a matrix, iterating until all columns are deleted efficie…
Design Memory Allocator
Design a memory allocator that simulates allocation and deallocation of memory blocks.
Smallest Value After Replacing With Sum of Prime Factors
Replace a number with the sum of its prime factors until it stabilizes, and return the smallest value.
Time to Cross a Bridge
Time to Cross a Bridge involves simulating worker movements using arrays and heaps to determine when the last worker cro…
Count Distinct Numbers on Board
Compute the number of distinct integers generated on a board using repeated modulo operations over a long sequence of da…
Separate the Digits in an Array
Given an array of positive integers, separate each integer into its individual digits while preserving the original orde…
Take Gifts From the Richest Pile
Take Gifts From the Richest Pile uses a heap to simulate the process of taking gifts from the richest pile over a number…
Find the Array Concatenation Value
Compute the array concatenation value efficiently using two-pointer scanning while maintaining a running total of concat…
Pass the Pillow
Pass the Pillow simulates the process of passing an item through a line of people, adjusting the direction based on time…
Find Score of an Array After Marking All Elements
The problem involves marking elements in an array and calculating the score based on adjacent elements.
Check Knight Tour Configuration
Validate a knight's movement configuration on an n x n chessboard to check if it forms a valid Knight's Tour.
Determine the Winner of a Bowling Game
Simulate a bowling game to determine the winner based on hit pins per turn for two players.
Sum in a Matrix
Calculate the maximum score by repeatedly removing the largest elements from each row of a 2D matrix efficiently using s…
Find the Losers of the Circular Game
Simulate a ball-passing game around a circle using array scanning and hash lookup to find friends who never receive the …
Minimum String Length After Removing Substrings
Determine the smallest string length after repeatedly removing AB or CD substrings using stack-based simulation techniqu…
Semi-Ordered Permutation
Find the minimum number of operations to convert a permutation into a semi-ordered permutation where 1 is first and n is…
Total Distance Traveled
Calculate the maximum distance a truck can travel using main and additional fuel tanks with controlled transfers.
Find Maximum Number of String Pairs
Find the maximum number of pairs of distinct strings from an array where one string is the reverse of the other.
Robot Collisions
Robot Collisions involves simulating robot movements and handling collisions with stack-based state management.
Relocate Marbles
Relocate marbles to new positions in an array by simulating moves, and return sorted occupied positions.
Faulty Keyboard
Simulate typing on a faulty keyboard where pressing 'i' reverses the string, requiring careful string manipulation track…
Last Visited Integers
This problem involves finding the last visited integer for each -1 in a given array by simulating a stack-like behavior.
Matrix Similarity After Cyclic Shifts
Determine if a matrix returns to its original state after performing cyclic row shifts k times using array and math patt…
Count Tested Devices After Test Operations
Simulate testing devices based on battery percentages to determine how many pass the test operations in sequence.
Double Modular Exponentiation
Solve the Double Modular Exponentiation problem by applying array manipulation and modular arithmetic to find good indic…
Minimum Number Game
The Minimum Number Game involves simulating moves by Alice and Bob on an array, sorting elements and appending them to a…
Ant on the Boundary
Solve the problem of counting how often an ant returns to a boundary based on the steps described in the input array.
Maximum Number of Operations With the Same Score I
Determine the maximum number of operations in an integer array where each operation must produce the same score.
Minimum Operations to Exceed Threshold Value II
Calculate the fewest operations to make every array element exceed a threshold using a min-heap simulation strategy effi…
Distribute Elements Into Two Arrays I
Distribute elements from a distinct integer array into two subarrays using a sequential simulation strategy for optimal …
Distribute Elements Into Two Arrays II
Distribute elements into two arrays based on conditions, utilizing a Binary Indexed Tree for efficient counting and simu…
Mark Elements on Array by Performing Queries
Efficiently mark elements in an array based on queries using scanning plus hash lookup to track marked indices and compu…
Water Bottles II
Compute the maximum number of water bottles you can drink by simulating exchanges with step-by-step math logic.
Find the Number of Distinct Colors Among the Balls
Efficiently track colors on balls using array scanning and hash lookup to return the count of distinct colors after each…
Minimum Number of Chairs in a Waiting Room
Calculate the minimum number of chairs needed in a waiting room using string simulation and event tracking efficiently.
Clear Digits
Remove all digits from a given string by applying a repeated operation to form the final string without digits.
Find The First Player to win K Games in a Row
Determine which player first wins k consecutive games using array simulation logic to track ongoing victories efficientl…
Find the Child Who Has the Ball After K Seconds
Find the child who holds the ball after k seconds of passing in a queue, considering reversals at both ends.
Find the N-th Value After K Seconds
Solve for the N-th value after K seconds by simulating array updates and using prefix sum techniques.
Find the Winning Player in Coin Game
In this game between Alice and Bob, players must pick coins summing to 115. Alice starts, and the goal is to determine t…
Design Neighbor Sum Service
Design a service that computes sums for adjacent and diagonal elements in a 2D grid.
Snake in Matrix
Solve the Snake in Matrix problem by simulating the snake's movement in a grid based on a series of directional commands…
Final Array State After K Multiplication Operations I
Solve the problem of determining the final state of an array after multiple multiplication operations using a priority q…
Final Array State After K Multiplication Operations II
Optimize the final state of an array after performing k multiplication operations with priority queues.
Hash Divided String
Hash Divided String requires splitting a string into equal parts and combining character values modulo 26 to form a new …
Find the K-th Character in String Game I
Find the K-th character in a progressively built string using math and bit manipulation efficiently.
Find the Sequence of Strings Appeared on the Screen
Simulate Alice typing a target string with a special keyboard that appends letters one by one. Solve using string simula…
Make Array Elements Equal to Zero
Learn how to transform an integer array to zeros using simulation and directional selection efficiently and reliably.
Stone Removal Game
Alice and Bob play a game of stone removal. Alice goes first, and the winner is the player who can make a move until the…
Transformed Array
Simulate operations on a circular array to return a transformed result array following specific rules.
Find Mirror Score of a String
Calculate the mirror score of a string using stack-based state management for matching letters efficiently and accuratel…
Zigzag Grid Traversal With Skip
Traverse a 2D grid in a zigzag pattern while skipping alternate cells, focusing on array and matrix manipulation challen…
Count Mentions Per User
Calculate how many times each user is mentioned across MESSAGE events, accounting for offline and online statuses effici…
Check If Digits Are Equal in String After Operations I
Simulate repeated adjacent digit sums modulo 10 until two digits remain, then check whether those final digits match.
Fruits Into Baskets II
Determine the number of fruit types that remain unplaced after all allocations in the "Fruits Into Baskets II" problem.
Find the Minimum Amount of Time to Brew Potions
This problem involves calculating the minimum time required for wizards to brew potions based on their skills and mana u…
Reverse Degree of a String
Calculate the reverse degree of a string by simulating operations on its characters based on their positions in the alph…
Minimum Pair Removal to Sort Array I
This problem asks for the minimum number of operations to make an array non-decreasing by removing pairs of elements.
Minimum Pair Removal to Sort Array II
The problem asks to find the minimum number of operations to make an array non-decreasing by removing pairs of elements.
Calculate Score After Performing Instructions
Simulate a series of add and jump instructions on arrays to compute the final score efficiently using array scanning and…
Resulting String After Adjacent Removals
This problem focuses on removing adjacent characters in a string using a stack-based approach until no more operations a…
Generate Tag for Video Caption
Transform a video caption into a valid hashtag by simulating capitalization rules and truncation for long words efficien…
Partition String
Partition a string into unique segments using hash table and string manipulation.
Process String with Special Operations I
Simulate a series of operations on a string to transform it into the desired result using special characters.
Process String with Special Operations II
Solve the problem of processing strings with special operations like '*' and '#' by simulating the rules left-to-right.