LeetCodechevron_rightCategorieschevron_rightsimulation
smart_toy

simulation

171 problems
Easy: 75Medium: 85Hard: 11

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

#TitleDifficulty
43

Multiply Strings

Multiply Strings requires simulating integer multiplication using only string operations without direct numeric conversi…

Medium
54

Spiral Matrix

Given an m x n matrix, return all elements in spiral order starting from the top-left corner.

Medium
59

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…

Medium
67

Add Binary

Add Binary involves summing two binary strings and returning the result as a binary string using math and string manipul…

Easy
68

Text Justification

Text Justification requires packing words into lines to match a specified width, ensuring even distribution of spaces.

Hard
258

Add Digits

Add Digits involves repeatedly summing digits of a number until a single digit is obtained.

Easy
289

Game of Life

Solve the Game of Life by updating each cell based on its eight neighbors using Array and Matrix simulation patterns eff…

Medium
412

Fizz Buzz

Generate a list from 1 to n replacing multiples of 3 with Fizz, 5 with Buzz, and both with FizzBuzz efficiently.

Easy
415

Add Strings

Given two non-negative integers as strings, sum them and return the result as a string without converting to integers di…

Easy
495

Teemo Attacking

Compute the total poisoned time Ashe experiences from Teemo's attacks using an array-based simulation approach efficient…

Easy
498

Diagonal Traverse

Traverse a matrix diagonally and return all elements in the specific zig-zag order required by the problem pattern.

Medium
537

Complex Number Multiplication

This problem requires multiplying two complex numbers, given in string form, and returning the result in the same format…

Medium
566

Reshape the Matrix

Reshape the Matrix involves transforming a 2D matrix into a new matrix with the same elements in row-major order, follow…

Easy
592

Fraction Addition and Subtraction

Solve fraction addition and subtraction by handling expressions, calculating results, and simplifying fractions to irred…

Medium
640

Solve the Equation

Solve the equation for the variable 'x' and determine its value or state if there is no solution or infinite solutions.

Medium
657

Robot Return to Origin

Judge whether a robot returns to the origin after a sequence of moves using string manipulation and simulation.

Easy
682

Baseball Game

Simulate baseball score operations using a stack-based approach to compute the final score after all operations.

Easy
735

Asteroid Collision

Determine the final positions of moving asteroids using a stack-based simulation for efficient collision resolution in l…

Medium
749

Contain Virus

Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…

Hard
832

Flipping an Image

Flip each row of a binary matrix horizontally and invert its values efficiently using a two-pointer scanning approach.

Easy
844

Backspace String Compare

Compare two strings after processing backspaces using efficient two-pointer scanning and careful invariant tracking to e…

Easy
867

Transpose Matrix

Transpose Matrix problem requires flipping a matrix's rows and columns to return the transposed version.

Easy
874

Walking Robot Simulation

The Walking Robot Simulation problem involves moving a robot in an infinite grid and calculating its furthest distance f…

Medium
885

Spiral Matrix III

Solve the Spiral Matrix III problem by simulating the movement across a matrix with specific constraints on direction an…

Medium
946

Validate Stack Sequences

Determine if a sequence of push and pop operations can produce the given popped array using a stack-based state approach…

Medium
950

Reveal Cards In Increasing Order

Determine the initial deck order to reveal cards in strictly increasing order using queue-driven simulation logic.

Medium
985

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…

Medium
999

Available Captures for Rook

This problem involves finding the number of pawns a rook can capture on a chessboard, considering obstacles like bishops…

Easy
1006

Clumsy Factorial

Compute the clumsy factorial of a number using a fixed rotation of multiply, divide, add, and subtract operations effici…

Medium
1041

Robot Bounded In Circle

Determine if a robot following a repeated instruction sequence stays within a bounded circle using math and string simul…

Medium
1094

Car Pooling

Determine if a car can handle multiple trips without exceeding its capacity using array sorting and event simulation tec…

Medium
1103

Distribute Candies to People

Distribute candies to people in a way that follows a mathematical pattern, ensuring the distribution is correct.

Easy
1222

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…

Medium
1252

Cells with Odd Values in a Matrix

This problem involves updating a matrix based on given indices and counting cells with odd values afterward.

Easy
1260

Shift 2D Grid

Shift 2D Grid requires shifting elements of a matrix by a given number of times, simulating step-by-step movement.

Easy
1275

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…

Easy
1324

Print Words Vertically

Transform a string into vertical columns by arranging each word character in array positions while trimming trailing spa…

Medium
1389

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…

Easy
1404

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.

Medium
1409

Queries on a Permutation With Key

This problem involves processing queries on a permutation using an array and binary indexed tree for efficient results.

Medium
1441

Build an Array With Stack Operations

Simulate stack operations to match a target array while processing numbers from 1 to n.

Medium
1503

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.

Medium
1518

Water Bottles

Maximize the number of water bottles you can drink by simulating the exchange process between full and empty bottles.

Easy
1535

Find the Winner of an Array Game

Determine the integer that wins an array game by achieving k consecutive victories through simulated pairwise comparison…

Medium
1545

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…

Medium
1560

Most Visited Sector in a Circular Track

Determine which sectors on a circular track are visited most frequently using array and simulation techniques efficientl…

Easy
1562

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…

Medium
1583

Count Unhappy Friends

Determine the number of unhappy friends in paired arrangements using array-based simulation for preference violations.

Medium
1599

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…

Medium
1603

Design Parking System

Implement a class to manage a parking lot with fixed slots for big, medium, and small cars, tracking occupancy efficient…

Easy
1646

Get Maximum in Generated Array

Compute the maximum value in a generated array using defined recurrence rules, leveraging array simulation techniques ef…

Easy
1680

Concatenation of Consecutive Binary Numbers

Calculate the decimal value of concatenated binary numbers from 1 to n using efficient bit manipulation techniques.

Medium
1688

Count of Matches in Tournament

Calculate the total matches in a tournament by simulating rounds and applying simple math rules for advancing teams.

Easy
1700

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.

Easy
1701

Average Waiting Time

Compute the average waiting time for customers using array traversal and simulation of a single chef processing orders s…

Medium
1706

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…

Medium
1801

Number of Orders in the Backlog

Determine the total number of unfulfilled buy and sell orders using heaps to simulate backlog processing efficiently in …

Medium
1806

Minimum Number of Operations to Reinitialize a Permutation

Find the minimum number of operations to reinitialize a permutation of size n using specific operations.

Medium
1823

Find the Winner of the Circular Game

Find the winner of a circular game by simulating the elimination process with a queue-driven approach.

Medium
1860

Incremental Memory Leak

Solve Incremental Memory Leak by simulating each second carefully and using math to reason about the crash time bound.

Medium
1894

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.

Medium
1910

Remove All Occurrences of a Substring

Remove all occurrences of a specified substring from a string using efficient stack-based state management.

Medium
1914

Cyclically Rotating a Grid

This problem requires cyclically rotating a grid by rotating each layer of the matrix counter-clockwise for a specified …

Medium
1920

Build Array from Permutation

The problem asks to build an array from a given permutation using an efficient approach.

Easy
1929

Concatenation of Array

This problem asks you to create an array of double the size, where each element is repeated twice in sequence.

Easy
1945

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.

Easy
2011

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.

Easy
2022

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.

Easy
2028

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…

Medium
2043

Simple Bank System

Design a simple bank system that processes transactions like withdrawals, deposits, and transfers while managing account…

Medium
2056

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…

Hard
2069

Walking Robot Simulation II

The Walking Robot Simulation II problem challenges you to simulate robot movements and track its position and direction …

Medium
2073

Time Needed to Buy Tickets

Calculate the total time for a specific person to buy all their tickets using queue-driven state processing.

Easy
2075

Decode the Slanted Ciphertext

Decode the Slanted Ciphertext problem requires decoding a slanted cipher using string manipulation and simulation based …

Medium
2079

Watering Plants

Simulate watering plants while managing a watering can's capacity, considering distance and refills.

Medium
2105

Watering Plants II

Simulate watering a row of plants with Alice and Bob using two-pointer scanning, tracking refills precisely for each ste…

Medium
2109

Adding Spaces to a String

Learn to efficiently insert spaces in a string using two-pointer scanning with invariant tracking in linear time.

Medium
2120

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.

Medium
2138

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.

Easy
2149

Rearrange Array Elements by Sign

Rearrange an array by alternating positive and negative integers using a two-pointer approach with invariant tracking.

Medium
2154

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 …

Easy
2161

Partition Array According to Given Pivot

Rearrange an array around a pivot while maintaining relative order using a two-pointer scanning approach efficiently.

Medium
2169

Count Operations to Obtain Zero

Simulate operations on two integers until one becomes zero, counting how many steps it takes to achieve the result.

Easy
2177

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.

Medium
2180

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…

Easy
2181

Merge Nodes in Between Zeros

This problem requires merging nodes between zeros in a linked list by summing up the values between consecutive zeros.

Medium
2201

Count Artifacts That Can Be Extracted

Count the number of artifacts that can be extracted after excavating specified grid cells.

Medium
2211

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…

Medium
2221

Find Triangular Sum of an Array

The problem asks for calculating the triangular sum of an array through repeated pairwise summation.

Medium
2243

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.

Easy
2257

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…

Medium
2293

Min Max Game

The Min Max Game problem requires simulating an array reduction process to find the last remaining number.

Easy
2295

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 …

Medium
2296

Design a Text Editor

Design a text editor that supports text manipulation and cursor navigation operations efficiently with linked-list-based…

Hard
2303

Calculate Amount Paid in Taxes

Calculate the total tax owed by iterating through sorted brackets and applying each rate incrementally to your income.

Easy
2326

Spiral Matrix IV

In this problem, you need to generate a matrix filled with values from a linked list in a spiral order.

Medium
2327

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…

Medium
2352

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…

Medium
2357

Make Array Zero by Subtracting Equal Amounts

Minimize operations to make all array elements zero by subtracting equal amounts in each operation.

Easy
2365

Task Scheduler II

Complete tasks in the optimal number of days by considering breaks and task type constraints.

Medium
2380

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.

Medium
2390

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…

Medium
2402

Meeting Rooms III

Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.

Hard
2460

Apply Operations to an Array

Transform an array by applying adjacent doubling operations and shifting zeros efficiently using two-pointer scanning te…

Easy
2462

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…

Medium
2482

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…

Medium
2500

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…

Easy
2502

Design Memory Allocator

Design a memory allocator that simulates allocation and deallocation of memory blocks.

Medium
2507

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.

Medium
2532

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…

Hard
2549

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…

Easy
2553

Separate the Digits in an Array

Given an array of positive integers, separate each integer into its individual digits while preserving the original orde…

Easy
2558

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…

Easy
2562

Find the Array Concatenation Value

Compute the array concatenation value efficiently using two-pointer scanning while maintaining a running total of concat…

Easy
2582

Pass the Pillow

Pass the Pillow simulates the process of passing an item through a line of people, adjusting the direction based on time…

Easy
2593

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.

Medium
2596

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.

Medium
2660

Determine the Winner of a Bowling Game

Simulate a bowling game to determine the winner based on hit pins per turn for two players.

Easy
2679

Sum in a Matrix

Calculate the maximum score by repeatedly removing the largest elements from each row of a 2D matrix efficiently using s…

Medium
2682

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 …

Easy
2696

Minimum String Length After Removing Substrings

Determine the smallest string length after repeatedly removing AB or CD substrings using stack-based simulation techniqu…

Easy
2717

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…

Easy
2739

Total Distance Traveled

Calculate the maximum distance a truck can travel using main and additional fuel tanks with controlled transfers.

Easy
2744

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.

Easy
2751

Robot Collisions

Robot Collisions involves simulating robot movements and handling collisions with stack-based state management.

Hard
2766

Relocate Marbles

Relocate marbles to new positions in an array by simulating moves, and return sorted occupied positions.

Medium
2810

Faulty Keyboard

Simulate typing on a faulty keyboard where pressing 'i' reverses the string, requiring careful string manipulation track…

Easy
2899

Last Visited Integers

This problem involves finding the last visited integer for each -1 in a given array by simulating a stack-like behavior.

Easy
2946

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…

Easy
2960

Count Tested Devices After Test Operations

Simulate testing devices based on battery percentages to determine how many pass the test operations in sequence.

Easy
2961

Double Modular Exponentiation

Solve the Double Modular Exponentiation problem by applying array manipulation and modular arithmetic to find good indic…

Medium
2974

Minimum Number Game

The Minimum Number Game involves simulating moves by Alice and Bob on an array, sorting elements and appending them to a…

Easy
3028

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.

Easy
3038

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.

Easy
3066

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…

Medium
3069

Distribute Elements Into Two Arrays I

Distribute elements from a distinct integer array into two subarrays using a sequential simulation strategy for optimal …

Easy
3072

Distribute Elements Into Two Arrays II

Distribute elements into two arrays based on conditions, utilizing a Binary Indexed Tree for efficient counting and simu…

Hard
3080

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…

Medium
3100

Water Bottles II

Compute the maximum number of water bottles you can drink by simulating exchanges with step-by-step math logic.

Medium
3160

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…

Medium
3168

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.

Easy
3174

Clear Digits

Remove all digits from a given string by applying a repeated operation to form the final string without digits.

Easy
3175

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…

Medium
3178

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.

Easy
3179

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.

Medium
3222

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…

Easy
3242

Design Neighbor Sum Service

Design a service that computes sums for adjacent and diagonal elements in a 2D grid.

Easy
3248

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…

Easy
3264

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…

Easy
3266

Final Array State After K Multiplication Operations II

Optimize the final state of an array after performing k multiplication operations with priority queues.

Hard
3271

Hash Divided String

Hash Divided String requires splitting a string into equal parts and combining character values modulo 26 to form a new …

Medium
3304

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.

Easy
3324

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…

Medium
3354

Make Array Elements Equal to Zero

Learn how to transform an integer array to zeros using simulation and directional selection efficiently and reliably.

Easy
3360

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…

Easy
3379

Transformed Array

Simulate operations on a circular array to return a transformed result array following specific rules.

Easy
3412

Find Mirror Score of a String

Calculate the mirror score of a string using stack-based state management for matching letters efficiently and accuratel…

Medium
3417

Zigzag Grid Traversal With Skip

Traverse a 2D grid in a zigzag pattern while skipping alternate cells, focusing on array and matrix manipulation challen…

Easy
3433

Count Mentions Per User

Calculate how many times each user is mentioned across MESSAGE events, accounting for offline and online statuses effici…

Medium
3461

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.

Easy
3477

Fruits Into Baskets II

Determine the number of fruit types that remain unplaced after all allocations in the "Fruits Into Baskets II" problem.

Easy
3494

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…

Medium
3498

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…

Easy
3507

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.

Easy
3510

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.

Hard
3522

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…

Medium
3561

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…

Medium
3582

Generate Tag for Video Caption

Transform a video caption into a valid hashtag by simulating capitalization rules and truncation for long words efficien…

Easy
3597

Partition String

Partition a string into unique segments using hash table and string manipulation.

Medium
3612

Process String with Special Operations I

Simulate a series of operations on a string to transform it into the desired result using special characters.

Medium
3614

Process String with Special Operations II

Solve the problem of processing strings with special operations like '*' and '#' by simulating the rules left-to-right.

Hard

Related Patterns

Simulation LeetCode Problems: 171 Solutions