← back

Simulation

Direct Simulation

Follow the described process step-by-step without a clever algorithmic shortcut. Maintain the necessary state and apply each operation as specified. Common for spiral matrix, zigzag conversion, string compression, and robot movement.

Direct Simulation

Some problems don't require a clever algorithm. They require you to do exactly what the problem says, step by step, without missing a boundary or an edge case. These are simulation problems, and they show up in interviews more than people expect. Spiral Matrix is the textbook example, but the category stretches to Game of Life, Zigzag Conversion, and Robot Bounded in Circle. The skill being tested is not algorithmic insight. It's disciplined state management.

What Makes a Problem a Simulation

A simulation problem gives you a set of rules and asks you to follow them. There's no recurrence relation to discover, no invariant to exploit. You move through the structure according to the stated process and collect or mutate values along the way. The challenge is that the rules interact with boundaries in ways that create subtle off-by-one errors, missed termination conditions, or accidental overwrites.

You're looking at a simulation when the problem describes a traversal pattern (spiral, diagonal, zigzag), a physical or cellular process (Game of Life's birth-and-death rules, a robot following commands), or any scenario where "just simulate it" is the entire strategy.

Spiral Matrix: The Canonical Example

Spiral Matrix (LC 54) asks you to return all elements of an m × n matrix in spiral order: left to right across the top, down the right side, right to left across the bottom, up the left side, then repeat inward. The process is well-defined. The difficulty is tracking when to stop and how to shrink the active region after each pass.

The cleanest approach uses four boundary variables, top, bot, left, right, that close inward as each edge is consumed. After traversing the top row, increment top. After the right column, decrement right. After the bottom row (if it still exists), decrement bot. After the left column (if it still exists), increment left. The loop continues while top <= bot and left <= right.

#### Walking Through a 3×4 Matrix

Start with this matrix:

1
2
3
 1  2  3  4
 5  6  7  8
 9 10 11 12

Initial boundaries: top=0, bot=2, left=0, right=3.

Pass 1, traverse top row left to right: collect 1, 2, 3, 4. Then top becomes 1. Traverse right column top to bottom: collect 8, 12. Then right becomes 2. Traverse bottom row right to left (top=1 <= bot=2): collect 11, 10, 9. Then bot becomes 1. Traverse left column bottom to top (left=0 <= right=2): collect 5. Then left becomes 1.

Pass 2, boundaries are now top=1, bot=1, left=1, right=2. Traverse top row: collect 6, 7. top becomes 2. Now top > bot, so the remaining two traversals are skipped (they'd double-count).

Final result: [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7].

The guard conditions if top <= bot and if left <= right before the bottom-row and left-column passes are critical. Without them, a matrix with more columns than rows would revisit cells on the final pass.

#### The Code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
def spiral_order(matrix):
    if not matrix:
        return []
    res = []
    top, bot = 0, len(matrix) - 1
    left, right = 0, len(matrix[0]) - 1

    while top <= bot and left <= right:
        for c in range(left, right + 1):
            res.append(matrix[top][c])
        top += 1

        for r in range(top, bot + 1):
            res.append(matrix[r][right])
        right -= 1

        if top <= bot:
            for c in range(right, left - 1, -1):
                res.append(matrix[bot][c])
            bot -= 1

        if left <= right:
            for r in range(bot, top - 1, -1):
                res.append(matrix[r][left])
            left += 1

    return res

Spiral Matrix II (LC 59) is the fill variant: instead of reading values out, you write incrementing integers into the same spiral pattern. The boundary logic is identical: only the operation inside each loop changes.

Other Simulation Problems

Zigzag Conversion (LC 6) asks you to rearrange a string as if it were written diagonally down and then up across a set of rows, then read row by row. The simulation tracks a current row index and a direction flag (+1 or -1). Each character is appended to its row's string. When the row index hits 0 or numRows - 1, the direction flips. Concatenate all rows at the end.

1
2
3
4
5
6
7
8
9
10
11
12
13
def convert(s, numRows):
    if numRows == 1:
        return s
    rows = ['' for _ in range(numRows)]
    row, direction = 0, 1
    for ch in s:
        rows[row] += ch
        if row == 0:
            direction = 1
        elif row == numRows - 1:
            direction = -1
        row += direction
    return ''.join(rows)

Game of Life (LC 289) is a cellular automaton where each cell lives or dies based on its eight neighbors. The constraint is that all updates must appear simultaneous: a cell updated early in your scan can't influence its neighbors' decisions. One approach is a second matrix. The in-place approach encodes the old state and new state together using extra bit values (e.g., 2 means "was dead, now alive"), then decodes in a second pass.

Robot Bounded in Circle (LC 1041) gives a sequence of commands (go forward, turn left, turn right) and asks whether the robot stays within a bounded region. You simulate one full cycle of commands. The robot is bounded if it ends at the origin or if it's not facing north (any non-north direction after one cycle means the robot traces a closed polygon over multiple cycles).

Why Boundary Handling Is the Real Challenge

The algorithmic heart of every simulation problem is the same: maintain state and apply rules. What trips people up is boundary conditions: the moment the spiral's width collapses to a single row, the moment the zigzag has only one row, the moment a Game of Life cell sits on the grid edge. Each of these requires an explicit check or a safe initialization that prevents an out-of-bounds access or an incorrect computation.

Approach simulation problems methodically: identify every piece of state you need to track, name it explicitly, and ask yourself what happens at each boundary before writing the loop. Trace through a small example by hand before coding. The code itself is usually short once the state is clear.

Complexity

Time complexity for matrix simulations is O(m×n)O(m \times n): every cell is visited exactly once. Space complexity is O(1)O(1) beyond the output array, since boundary tracking uses only a fixed number of variables. For Game of Life's in-place variant, the second pass to decode the bit-encoded values keeps it O(1)O(1) extra space as well.

Recognizing this pattern

You're probably looking at direct simulation when:

  • The problem describes a step-by-step process and asks for the state after k steps or until a terminal condition.
  • There's no obvious closed-form shortcut: the rules are the answer.
  • A grid is being walked, rotated, or updated in place according to local rules.
  • The input itself is small enough that "just do what it says" fits comfortably in the time limit.

Common templates:

  • Direction-vector grid walk: keep (dx, dy) and rotate when you hit a boundary or obstacle. Example: Spiral Matrix.
  • Local-rule cellular update: read every cell's neighborhood and write the next state, often with bit-packing for in-place. Example: Game of Life.
  • Bounded-process detection: simulate a few cycles and check whether the agent returns to the origin or repeats. Example: Robot Bounded In Circle.
  • Tick-by-tick state machine: advance a clock, apply rules per element, possibly cap the loop with cycle detection. Example: Rotting Oranges.

Practice Problems (466)

6 Zigzag Conversion
8 String to Integer (atoi)
12 Integer to Roman
13 Roman to Integer
14 Longest Common Prefix
31 Next Permutation
38 Count and Say
43 Multiply Strings
54 Spiral Matrix
58 Length of Last Word
59 Spiral Matrix II
65 Valid Number
68 Text Justification
151 Reverse Words in a String
165 Compare Version Numbers
189 Rotate Array
223 Rectangle Area
228 Summary Ranges
273 Integer to English Words
335 Self Crossing
412 Fizz Buzz
419 Battleships in a Board
420 Strong Password Checker
427 Construct Quad Tree
434 Number of Segments in a String
443 String Compression
463 Island Perimeter
468 Validate IP Address
481 Magical String
482 License Key Formatting
485 Max Consecutive Ones
492 Construct the Rectangle
495 Teemo Attacking
520 Detect Capital
521 Longest Uncommon Subsequence I
522 Longest Uncommon Subsequence II
537 Complex Number Multiplication
541 Reverse String II
551 Student Attendance Record I
553 Optimal Division
556 Next Greater Element III
557 Reverse Words in a String III
566 Reshape the Matrix
587 Erect the Fence
592 Fraction Addition and Subtraction
593 Valid Square
598 Range Addition II
640 Solve the Equation
649 Dota2 Senate
657 Robot Return to Origin
661 Image Smoother
667 Beautiful Arrangement II
682 Baseball Game
709 To Lower Case
717 1-bit and 2-bit Characters
722 Remove Comments
747 Largest Number At Least Twice of Others
766 Toeplitz Matrix
794 Valid Tic-Tac-Toe State
806 Number of Lines To Write String
807 Max Increase to Keep City Skyline
812 Largest Triangle Area
824 Goat Latin
830 Positions of Large Groups
831 Masking Personal Information
832 Flipping an Image
833 Find And Replace in String
835 Image Overlap
836 Rectangle Overlap
838 Push Dominoes
840 Magic Squares In Grid
844 Backspace String Compare
860 Lemonade Change
867 Transpose Matrix
874 Walking Robot Simulation
880 Decoded String at Index
883 Projection Area of 3D Shapes
885 Spiral Matrix III
892 Surface Area of 3D Shapes
908 Smallest Range I
910 Smallest Range II
917 Reverse Only Letters
927 Three Equal Parts
932 Beautiful Array
936 Stamping The Sequence
942 DI String Match
944 Delete Columns to Make Sorted
946 Validate Stack Sequences
950 Reveal Cards In Increasing Order
955 Delete Columns to Make Sorted II
969 Pancake Sorting
976 Largest Perimeter Triangle
984 String Without AAA or BBB
985 Sum of Even Numbers After Queries
991 Broken Calculator
999 Available Captures for Rook
1033 Moving Stones Until Consecutive
1037 Valid Boomerang
1041 Robot Bounded In Circle
1078 Occurrences After Bigram
1089 Duplicate Zeros
1093 Statistics from a Large Sample
1103 Distribute Candies to People
1108 Defanging an IP Address
1144 Decrease Elements To Make Array Zigzag
1163 Last Substring in Lexicographical Order
1169 Invalid Transactions
1184 Distance Between Bus Stops
1217 Minimum Cost to Move Chips to The Same Position
1221 Split a String in Balanced Strings
1222 Queens That Can Attack the King
1232 Check If It Is a Straight Line
1247 Minimum Swaps to Make Strings Equal
1252 Cells with Odd Values in a Matrix
1253 Reconstruct a 2-Row Binary Matrix
1266 Minimum Time Visiting All Points
1275 Find Winner on a Tic Tac Toe Game
1287 Element Appearing More Than 25% In Sorted Array
1291 Sequential Digits
1304 Find N Unique Integers Sum up to Zero
1309 Decrypt String from Alphabet to Integer Mapping
1313 Decompress Run-Length Encoded List
1324 Print Words Vertically
1328 Break a Palindrome
1362 Closest Divisors
1374 Generate a String With Characters That Have Odd Counts
1389 Create Target Array in the Given Order
1390 Four Divisors
1401 Circle and Rectangle Overlapping
1414 Find the Minimum Number of Fibonacci Numbers Whose Sum Is K
1417 Reformat The String
1431 Kids With the Greatest Number of Candies
1437 Check If All 1's Are at Least Length K Places Away
1441 Build an Array With Stack Operations
1446 Consecutive Characters
1450 Number of Students Doing Homework at a Given Time
1455 Check If a Word Occurs As a Prefix of Any Word in a Sentence
1470 Shuffle the Array
1476 Subrectangle Queries
1491 Average Salary Excluding the Minimum and Maximum Salary
1503 Last Moment Before All Ants Fall Out of a Plank
1507 Reformat Date
1518 Water Bottles
1528 Shuffle String
1529 Minimum Suffix Flips
1534 Count Good Triplets
1535 Find the Winner of an Array Game
1545 Find Kth Bit in Nth Binary String
1550 Three Consecutive Odds
1556 Thousand Separator
1560 Most Visited Sector in a Circular Track
1566 Detect Pattern of Length M Repeated K or More Times
1576 Replace All ?'s to Avoid Consecutive Repeating Characters
1582 Special Positions in a Binary Matrix
1583 Count Unhappy Friends
1592 Rearrange Spaces Between Words
1598 Crawler Log Folder
1599 Maximum Profit of Operating a Centennial Wheel
1603 Design Parking System
1606 Find Servers That Handled Most Number of Requests
1620 Coordinate With Maximum Network Quality
1629 Slowest Key
1638 Count Substrings That Differ by One Character
1646 Get Maximum in Generated Array
1656 Design an Ordered Stream
1662 Check If Two String Arrays are Equivalent
1678 Goal Parser Interpretation
1689 Partitioning Into Minimum Number Of Deci-Binary Numbers
1694 Reformat Phone Number
1700 Number of Students Unable to Eat Lunch
1701 Average Waiting Time
1702 Maximum Binary String After Change
1706 Where Will the Ball Fall
1725 Number Of Rectangles That Can Form The Largest Square
1736 Latest Time by Replacing Hidden Digits
1752 Check if Array Is Sorted and Rotated
1758 Minimum Changes To Make Alternating Binary String
1773 Count Items Matching a Rule
1779 Find Nearest Point That Has the Same X or Y Coordinate
1784 Check if Binary String Has at Most One Segment of Ones
1806 Minimum Number of Operations to Reinitialize a Permutation
1816 Truncate Sentence
1822 Sign of the Product of an Array
1823 Find the Winner of the Circular Game
1828 Queries on Number of Points Inside a Circle
1844 Replace All Digits with Characters
1848 Minimum Distance to the Target Element
1850 Minimum Adjacent Swaps to Reach the Kth Smallest Number
1859 Sorting the Sentence
1860 Incremental Memory Leak
1869 Longer Contiguous Segments of Ones than Zeros
1880 Check if Word Equals Summation of Two Words
1904 The Number of Full Rounds You Have Played
1909 Remove One Element to Make the Array Strictly Increasing
1910 Remove All Occurrences of a Substring
1920 Build Array from Permutation
1925 Count Square Sum Triples
1929 Concatenation of Array
1945 Sum of Digits of String After Convert
1957 Delete Characters to Make Fancy String
1958 Check if Move is Legal
1961 Check If String Is a Prefix of Array
1967 Number of Strings That Appear as Substrings in Word
2000 Reverse Prefix of Word
2011 Final Value of Variable After Performing Operations
2018 Check if Word Can Be Placed In Crossword
2022 Convert 1D Array Into 2D Array
2028 Find Missing Observations
2042 Check if Numbers Are Ascending in a Sentence
2043 Simple Bank System
2047 Number of Valid Words in a Sentence
2048 Next Greater Numerically Balanced Number
2057 Smallest Index With Equal Value
2069 Walking Robot Simulation II
2073 Time Needed to Buy Tickets
2075 Decode the Slanted Ciphertext
2079 Watering Plants
2081 Sum of k-Mirror Numbers
2109 Adding Spaces to a String
2114 Maximum Number of Words Found in Sentences
2120 Execution of All Suffix Instructions Staying in a Grid
2124 Check if All A's Appears Before All B's
2125 Number of Laser Beams in a Bank
2129 Capitalize the Title
2138 Divide a String Into Groups of Size k
2148 Count Elements With Strictly Smaller and Greater Elements
2162 Minimum Cost to Set Cooking Time
2166 Design Bitset
2169 Count Operations to Obtain Zero
2177 Find Three Consecutive Integers That Sum to a Given Number
2185 Counting Words With a Given Prefix
2194 Cells in a Range on an Excel Sheet
2200 Find All K-Distant Indices in an Array
2201 Count Artifacts That Can Be Extracted
2210 Count Hills and Valleys in an Array
2221 Find Triangular Sum of an Array
2232 Minimize Result by Adding Parentheses to Expression
2235 Add Two Integers
2239 Find Closest Number to Zero
2240 Number of Ways to Buy Pens and Pencils
2241 Design an ATM Machine
2243 Calculate Digit Sum of a String
2249 Count Lattice Points Inside a Circle
2255 Count Prefixes of a Given String
2257 Count Unguarded Cells in the Grid
2264 Largest 3-Same-Digit Number in String
2278 Percentage of Letter in String
2280 Minimum Lines to Represent a Line Chart
2288 Apply Discount to Prices
2293 Min Max Game
2299 Strong Password Checker II
2303 Calculate Amount Paid in Taxes
2315 Count Asterisks
2319 Check if Matrix Is X-Matrix
2375 Construct Smallest Number From DI String
2396 Strictly Palindromic Number
2409 Count Days Spent Together
2432 The Employee That Worked on the Longest Task
2437 Number of Valid Clock Times
2443 Sum of Number and Its Reverse
2446 Determine if Two Events Have Conflict
2447 Number of Subarrays With GCD Equal to K
2452 Words Within Two Edits of Dictionary
2455 Average Value of Even Numbers That Are Divisible by Three
2460 Apply Operations to an Array
2468 Split Message Based on Limit
2469 Convert the Temperature
2470 Number of Subarrays With LCM Equal to K
2481 Minimum Cuts to Divide a Circle
2482 Difference Between Ones and Zeros in Row and Column
2490 Circular Sentence
2496 Maximum Value of a String in an Array
2502 Design Memory Allocator
2507 Smallest Value After Replacing With Sum of Prime Factors
2509 Cycle Length Queries in a Tree
2511 Maximum Enemy Forts That Can Be Captured
2515 Shortest Distance to Target String in a Circular Array
2525 Categorize Box According to Criteria
2526 Find Consecutive Integers from a Data Stream
2532 Time to Cross a Bridge
2541 Minimum Operations to Make Array Equal II
2549 Count Distinct Numbers on Board
2553 Separate the Digits in an Array
2562 Find the Array Concatenation Value
2579 Count Total Number of Colored Cells
2582 Pass the Pillow
2586 Count the Number of Vowel Strings in Range
2589 Minimum Time to Complete All Tasks
2591 Distribute Money to Maximum Children
2593 Find Score of an Array After Marking All Elements
2596 Check Knight Tour Configuration
2600 K Items With the Maximum Sum
2614 Prime In Diagonal
2639 Find the Width of Columns of a Grid
2643 Row With Maximum Ones
2644 Find the Maximum Divisibility Score
2651 Calculate Delayed Arrival Time
2652 Sum Multiples
2656 Maximum Sum With Exactly K Elements
2660 Determine the Winner of a Bowling Game
2672 Number of Adjacent Elements With the Same Color
2678 Number of Senior Citizens
2679 Sum in a Matrix
2682 Find the Losers of the Circular Game
2706 Buy Two Chocolates
2710 Remove Trailing Zeros From a String
2711 Difference of Number of Distinct Values on Diagonals
2717 Semi-Ordered Permutation
2718 Sum of Matrix After Queries
2729 Check if The Number is Fascinating
2731 Movement of Robots
2733 Neither Minimum nor Maximum
2735 Collecting Chocolates
2739 Total Distance Traveled
2740 Find the Value of the Partition
2769 Find the Maximum Achievable Number
2778 Sum of Squares of Special Elements
2788 Split Strings by Separator
2798 Number of Employees Who Met the Target
2800 Shortest String That Contains Three Strings
2806 Account Balance After Rounded Purchase
2810 Faulty Keyboard
2828 Check if a String Is an Acronym of Words
2829 Determine the Minimum Sum of a k-avoiding Array
2833 Furthest Point From Origin
2834 Find the Minimum Possible Sum of a Beautiful Array
2839 Check if Strings Can be Made Equal With Operations I
2843 Count Symmetric Integers
2849 Determine if a Cell Is Reachable at a Given Time
2855 Minimum Right Shifts to Sort the Array
2860 Happy Students
2862 Maximum Element-Sum of a Complete Subset of Indices
2864 Maximum Odd Binary Number
2869 Minimum Operations to Collect Elements
2894 Divisible and Non-divisible Sums Difference
2899 Last Visited Integers
2903 Find Indices With Index and Value Difference I
2916 Subarrays Distinct Element Sum of Squares II
2923 Find Champion I
2934 Minimum Operations to Maximize Last Elements in Arrays
2937 Make Three Strings Equal
2942 Find Words Containing Character
2943 Maximize Area of Square Hole in Grid
2946 Matrix Similarity After Cyclic Shifts
2951 Find the Peaks
2960 Count Tested Devices After Test Operations
2970 Count the Number of Incremovable Subarrays I
2974 Minimum Number Game
3000 Maximum Area of Longest Diagonal Rectangle
3001 Minimum Moves to Capture The Queen
3010 Divide an Array Into Subarrays With Minimum Cost I
3019 Number of Changing Keys
3021 Alice and Bob Playing Flower Game
3024 Type of Triangle
3028 Ant on the Boundary
3030 Find the Grid of Region Average
3033 Modify the Matrix
3038 Maximum Number of Operations With the Same Score I
3044 Most Frequent Prime
3047 Find the Largest Area of Square Inside Two Rectangles
3065 Minimum Operations to Exceed Threshold Value I
3069 Distribute Elements Into Two Arrays I
3071 Minimum Operations to Write the Letter Y on a Grid
3074 Apple Redistribution into Boxes
3079 Find the Sum of Encrypted Integers
3084 Count Substrings Starting and Ending with Given Character
3091 Apply Operations to Make Sum of Array Greater Than or Equal to k
3099 Harshad Number
3100 Water Bottles II
3101 Count Alternating Subarrays
3102 Minimize Manhattan Distances
3105 Longest Strictly Increasing or Strictly Decreasing Subarray
3106 Lexicographically Smallest String After Operations With Constraint
3107 Minimum Operations to Make Median of Array Equal to K
3110 Score of a String
3114 Latest Time You Can Obtain After Replacing Characters
3115 Maximum Prime Difference
3127 Make a Square with the Same Color
3131 Find the Integer Added to Array I
3136 Valid Word
3139 Minimum Cost to Equalize Array
3142 Check if Grid Satisfies Conditions
3151 Special Array I
3163 String Compression III
3168 Minimum Number of Chairs in a Waiting Room
3175 Find The First Player to win K Games in a Row
3178 Find the Child Who Has the Ball After K Seconds
3190 Find Minimum Operations to Make All Elements Divisible by Three
3195 Find the Minimum Area to Cover All Ones I
3197 Find the Minimum Area to Cover All Ones II
3200 Maximum Height of a Triangle
3210 Find the Encrypted String
3216 Lexicographically Smallest String After a Swap
3232 Find if Digit Game Can Be Won
3242 Design Neighbor Sum Service
3248 Snake in Matrix
3264 Final Array State After K Multiplication Operations I
3266 Final Array State After K Multiplication Operations II
3271 Hash Divided String
3274 Check if Two Chessboard Squares Have the Same Color
3285 Find Indices of Stable Mountains
3300 Minimum Element After Replacement With Digit Sum
3309 Maximum Possible Number by Binary Concatenation
3324 Find the Sequence of Strings Appeared on the Screen
3330 Find the Original Typed String I
3340 Check Balanced String
3345 Smallest Divisible Digit Product I
3349 Adjacent Increasing Subarrays Detection I
3360 Stone Removal Game
3379 Transformed Array
3386 Button with Longest Push Time
3392 Count Subarrays of Length Three With a Condition
3402 Minimum Operations to Make Columns Strictly Increasing
3423 Maximum Difference Between Adjacent Elements in a Circular Array
3433 Count Mentions Per User
3452 Sum of Good Numbers
3456 Find Special Substring of Length K
3461 Check If Digits Are Equal in String After Operations I
3468 Find the Number of Copy Arrays
3492 Maximum Containers on a Ship
3498 Reverse Degree of a String
3507 Minimum Pair Removal to Sort Array I
3510 Minimum Pair Removal to Sort Array II
3512 Minimum Operations to Make Array Sum Divisible by K
3516 Find Closest Person
3522 Calculate Score After Performing Instructions
3536 Maximum Product of Two Digits
3560 Find Minimum Log Transportation Cost
3576 Transform Array to All Equal Elements
3582 Generate Tag for Video Caption
3590 Kth Smallest Path XOR Sum
3598 Longest Common Prefix Between Adjacent Strings After Removals
3602 Hexadecimal and Hexatrigesimal Conversion
3609 Minimum Moves to Reach Target in Grid
3612 Process String with Special Operations I
3614 Process String with Special Operations II
3622 Check Divisibility by Digit Sum and Product
3637 Trionic Array I
3653 XOR After Range Multiplication Queries I
3655 XOR After Range Multiplication Queries II
3675 Minimum Operations to Transform String
3680 Generate Schedule
3683 Earliest Time to Finish One Task
3697 Compute Decimal Representation
3701 Compute Alternating Sum
3708 Longest Fibonacci Subarray
3724 Minimum Operations to Transform Array
3726 Remove Zeros in Decimal Representation
3736 Minimum Moves to Equal Array Elements III
3777 Minimum Deletions to Make Alternating Substring
3782 Last Remaining Integer After Alternating Deletion Operations
3789 Minimum Cost to Acquire Required Items
3794 Reverse String Prefix
3798 Largest Even Number
3800 Minimum Cost to Make Two Binary Strings Equal
3809 Best Reachable Tower
3813 Vowel-Consonant Score
3818 Minimum Prefix Removal to Make Array Strictly Increasing
3819 Rotate Non Negative Elements
3833 Count Dominant Indices
3834 Merge Adjacent Equal Elements
3838 Weighted Word Mapping
3842 Toggle Light Bulbs
3847 Find the Score Difference in a Game
3853 Merge Close Characters
3856 Trim Trailing Vowels