面试场景
高频考察问题建模、边界条件与口头表达的清晰度。
常见误区
只背模板不解释为什么,容易在追问里失分。
练习策略
每轮练 3-5 题,固定复盘复杂度和可替代解法。
推荐练习顺序
字符串相乘
Multiply Strings requires simulating integer multiplication using only string operations without direct numeric conversi…
螺旋矩阵
Given an m x n matrix, return all elements in spiral order starting from the top-left corner.
螺旋矩阵 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 involves summing two binary strings and returning the result as a binary string using math and string manipul…
文本左右对齐
Text Justification requires packing words into lines to match a specified width, ensuring even distribution of spaces.
各位相加
Add Digits involves repeatedly summing digits of a number until a single digit is obtained.
生命游戏
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.
字符串相加
Given two non-negative integers as strings, sum them and return the result as a string without converting to integers di…
提莫攻击
Compute the total poisoned time Ashe experiences from Teemo's attacks using an array-based simulation approach efficient…
对角线遍历
Traverse a matrix diagonally and return all elements in the specific zig-zag order required by the problem pattern.
复数乘法
This problem requires multiplying two complex numbers, given in string form, and returning the result in the same format…
重塑矩阵
Reshape the Matrix involves transforming a 2D matrix into a new matrix with the same elements in row-major order, follow…
分数加减运算
Solve fraction addition and subtraction by handling expressions, calculating results, and simplifying fractions to irred…
求解方程
Solve the equation for the variable 'x' and determine its value or state if there is no solution or infinite solutions.
机器人能否返回原点
Judge whether a robot returns to the origin after a sequence of moves using string manipulation and simulation.
棒球比赛
Simulate baseball score operations using a stack-based approach to compute the final score after all operations.
小行星碰撞
Determine the final positions of moving asteroids using a stack-based simulation for efficient collision resolution in l…
隔离病毒
Contain Virus involves using array-based Depth-First Search to contain viral spread by building walls around infected re…
翻转图像
Flip each row of a binary matrix horizontally and invert its values efficiently using a two-pointer scanning approach.
比较含退格的字符串
Compare two strings after processing backspaces using efficient two-pointer scanning and careful invariant tracking to e…
转置矩阵
Transpose Matrix problem requires flipping a matrix's rows and columns to return the transposed version.
模拟行走机器人
The Walking Robot Simulation problem involves moving a robot in an infinite grid and calculating its furthest distance f…
螺旋矩阵 III
Solve the Spiral Matrix III problem by simulating the movement across a matrix with specific constraints on direction an…
验证栈序列
Determine if a sequence of push and pop operations can produce the given popped array using a stack-based state approach…
按递增顺序显示卡牌
Determine the initial deck order to reveal cards in strictly increasing order using queue-driven simulation logic.
查询后的偶数和
Efficiently update an integer array based on queries and compute the sum of even numbers after each modification using s…
可以被一步捕获的棋子数
This problem involves finding the number of pawns a rook can capture on a chessboard, considering obstacles like bishops…
笨阶乘
Compute the clumsy factorial of a number using a fixed rotation of multiply, divide, add, and subtract operations effici…
困于环中的机器人
Determine if a robot following a repeated instruction sequence stays within a bounded circle using math and string simul…
拼车
Determine if a car can handle multiple trips without exceeding its capacity using array sorting and event simulation tec…
分糖果 II
Distribute candies to people in a way that follows a mathematical pattern, ensuring the distribution is correct.
可以攻击国王的皇后
Identify all black queens on an 8x8 chessboard that can attack the white king using array and matrix simulation techniqu…
奇数值单元格的数目
This problem involves updating a matrix based on given indices and counting cells with odd values afterward.
二维网格迁移
Shift 2D Grid requires shifting elements of a matrix by a given number of times, simulating step-by-step movement.
找出井字棋的获胜者
Determine the winner of a Tic Tac Toe game by scanning moves and using hash lookups for rows, columns, and diagonals eff…
竖直打印单词
Transform a string into vertical columns by arranging each word character in array positions while trimming trailing spa…
按既定顺序创建目标数组
Learn how to efficiently create a target array by inserting elements at specified indices using array simulation techniq…
将二进制表示减到 1 的步骤数
Determine the number of steps to reduce a binary representation of a number to 1 by following specific rules.
查询带键的排列
This problem involves processing queries on a permutation using an array and binary indexed tree for efficient results.
用栈操作构建数组
Simulate stack operations to match a target array while processing numbers from 1 to n.
所有蚂蚁掉下来前的最后一刻
This problem involves simulating ant movement on a plank to determine the last moment before all ants fall off.
换水问题
Maximize the number of water bottles you can drink by simulating the exchange process between full and empty bottles.
找出数组游戏的赢家
Determine the integer that wins an array game by achieving k consecutive victories through simulated pairwise comparison…
找出第 N 个二进制字符串中的第 K 位
Determine the k-th bit in the n-th binary string using a recursive construction that inverts and reverses previous strin…
圆形赛道上经过次数最多的扇区
Determine which sectors on a circular track are visited most frequently using array and simulation techniques efficientl…
查找大小为 M 的最新分组
Determine the latest step where a contiguous group of ones of exact length m exists using array scanning and hash tracki…
统计不开心的朋友
Determine the number of unhappy friends in paired arrangements using array-based simulation for preference violations.
经营摩天轮的最大利润
Maximize the profit from operating a Centennial Wheel by determining the optimal number of rotations based on customer a…
设计停车系统
Implement a class to manage a parking lot with fixed slots for big, medium, and small cars, tracking occupancy efficient…
获取生成数组中的最大值
Compute the maximum value in a generated array using defined recurrence rules, leveraging array simulation techniques ef…
连接连续二进制数字
Calculate the decimal value of concatenated binary numbers from 1 to n using efficient bit manipulation techniques.
比赛中的配对次数
Calculate the total matches in a tournament by simulating rounds and applying simple math rules for advancing teams.
无法吃午餐的学生数量
Simulate a queue of students with sandwich preferences and determine how many can't eat based on available sandwiches.
平均等待时间
Compute the average waiting time for customers using array traversal and simulation of a single chef processing orders s…
球会落何处
Determine where each ball exits a diagonal board grid or if it gets stuck, using matrix simulation with careful traversa…
积压订单中的订单总数
Determine the total number of unfulfilled buy and sell orders using heaps to simulate backlog processing efficiently in …
还原排列的最少操作步数
Find the minimum number of operations to reinitialize a permutation of size n using specific operations.
找出游戏的获胜者
Find the winner of a circular game by simulating the elimination process with a queue-driven approach.
增长的内存泄露
Solve Incremental Memory Leak by simulating each second carefully and using math to reason about the crash time bound.
找到需要补充粉笔的学生编号
Identify the first student who will run out of chalk using a simulation with prefix sums and binary search.
删除一个字符串中所有出现的给定子字符串
Remove all occurrences of a specified substring from a string using efficient stack-based state management.
循环轮转矩阵
This problem requires cyclically rotating a grid by rotating each layer of the matrix counter-clockwise for a specified …
基于排列构建数组
The problem asks to build an array from a given permutation using an efficient approach.
数组串联
This problem asks you to create an array of double the size, where each element is repeated twice in sequence.
字符串转化后的各位数字之和
Convert a lowercase string into digits and repeatedly sum them k times using a direct string plus simulation approach.
执行操作后的变量值
Compute the final value of X by simulating each string operation in the array sequentially with careful tracking.
将一维数组转变成二维数组
Convert a 1D integer array into a structured 2D array with specified rows and columns using all elements sequentially.
找出缺失的观测数据
Given a set of dice rolls, calculate the missing observations based on the mean and return them or determine if it's imp…
简易银行系统
Design a simple bank system that processes transactions like withdrawals, deposits, and transfers while managing account…
棋盘上有效移动组合的数目
Given a set of pieces on a chessboard, calculate the number of valid move combinations without overlap using backtrackin…
模拟行走机器人 II
The Walking Robot Simulation II problem challenges you to simulate robot movements and track its position and direction …
买票需要的时间
Calculate the total time for a specific person to buy all their tickets using queue-driven state processing.
解码斜向换位密码
Decode the Slanted Ciphertext problem requires decoding a slanted cipher using string manipulation and simulation based …
给植物浇水
Simulate watering plants while managing a watering can's capacity, considering distance and refills.
给植物浇水 II
Simulate watering a row of plants with Alice and Bob using two-pointer scanning, tracking refills precisely for each ste…
向字符串添加空格
Learn to efficiently insert spaces in a string using two-pointer scanning with invariant tracking in linear time.
执行所有后缀指令
Simulate robot moves from every instruction index on an n x n grid, counting valid steps without leaving boundaries.
将字符串拆分为若干长度为 k 的组
Divide a string into equal groups of size k, using a fill character to complete the last group if needed.
按符号重排数组
Rearrange an array by alternating positive and negative integers using a two-pointer approach with invariant tracking.
将找到的值乘以 2
The "Keep Multiplying Found Values by Two" problem involves repeatedly multiplying a number by two if it is found in an …
根据给定数字划分数组
Rearrange an array around a pivot while maintaining relative order using a two-pointer scanning approach efficiently.
得到 0 的操作数
Simulate operations on two integers until one becomes zero, counting how many steps it takes to achieve the result.
找到和为给定整数的三个连续整数
Given a number, find three consecutive integers that sum to it, or return an empty array if no such integers exist.
统计各位数字之和为偶数的整数个数
Solve this Easy Math plus Simulation problem by counting numbers whose digit sums are even up to a given limit efficient…
合并零之间的节点
This problem requires merging nodes between zeros in a linked list by summing up the values between consecutive zeros.
统计可以提取的工件
Count the number of artifacts that can be extracted after excavating specified grid cells.
统计道路上的碰撞次数
Count Collisions on a Road is a problem where you calculate the number of car collisions based on their movements in a s…
数组的三角和
The problem asks for calculating the triangular sum of an array through repeated pairwise summation.
计算字符串的数字和
Learn how to repeatedly sum digit groups in a string until its length is at most k using string simulation techniques.
统计网格图中没有被保卫的格子数
Solve Count Unguarded Cells in the Grid by marking guard sight lines across a blocked matrix and counting untouched empt…
极大极小游戏
The Min Max Game problem requires simulating an array reduction process to find the last remaining number.
替换数组中的元素
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 that supports text manipulation and cursor navigation operations efficiently with linked-list-based…
计算应缴税款总额
Calculate the total tax owed by iterating through sorted brackets and applying each rate incrementally to your income.
螺旋矩阵 IV
In this problem, you need to generate a matrix filled with values from a linked list in a spiral order.
知道秘密的人数
Calculate how many people know a secret over n days using state transition dynamic programming and careful simulation of…
相等行列对
Identify all pairs of rows and columns in a square matrix that contain identical elements in the same sequence efficient…
使数组中所有元素都等于零
Minimize operations to make all array elements zero by subtracting equal amounts in each operation.
任务调度器 II
Complete tasks in the optimal number of days by considering breaks and task type constraints.
二进制字符串重新安排顺序需要的时间
Calculate the exact seconds required to convert all 01 pairs into 10 in a binary string using state transitions.
从字符串中移除星号
Remove all stars from a string by simulating the removal process using a stack to manage characters and stars efficientl…
会议室 III
Determine which meeting room holds the most meetings by simulating room assignments with precise time tracking.
对数组执行操作
Transform an array by applying adjacent doubling operations and shifting zeros efficiently using two-pointer scanning te…
雇佣 K 位工人的总代价
Optimize the total cost of hiring exactly k workers using a two-pointer approach with invariant tracking and priority qu…
行和列中一和零的差值
This problem requires computing a difference matrix based on the ones and zeros in each row and column of a binary matri…
删除每行中的最大值
Calculate the total of removed maximum values from each row of a matrix, iterating until all columns are deleted efficie…
设计内存分配器
Design a memory allocator that simulates allocation and deallocation of memory blocks.
使用质因数之和替换后可以取到的最小值
Replace a number with the sum of its prime factors until it stabilizes, and return the smallest value.
过桥的时间
Time to Cross a Bridge involves simulating worker movements using arrays and heaps to determine when the last worker cro…
统计桌面上的不同数字
Compute the number of distinct integers generated on a board using repeated modulo operations over a long sequence of da…
分割数组中数字的数位
Given an array of positive integers, separate each integer into its individual digits while preserving the original orde…
从数量最多的堆取走礼物
Take Gifts From the Richest Pile uses a heap to simulate the process of taking gifts from the richest pile over a number…
找出数组的串联值
Compute the array concatenation value efficiently using two-pointer scanning while maintaining a running total of concat…
递枕头
Pass the Pillow simulates the process of passing an item through a line of people, adjusting the direction based on time…
标记所有元素后数组的分数
The problem involves marking elements in an array and calculating the score based on adjacent elements.
检查骑士巡视方案
Validate a knight's movement configuration on an n x n chessboard to check if it forms a valid Knight's Tour.
保龄球游戏的获胜者
Simulate a bowling game to determine the winner based on hit pins per turn for two players.
矩阵中的和
Calculate the maximum score by repeatedly removing the largest elements from each row of a 2D matrix efficiently using s…
找出转圈游戏输家
Simulate a ball-passing game around a circle using array scanning and hash lookup to find friends who never receive the …
删除子串后的字符串最小长度
Determine the smallest string length after repeatedly removing AB or CD substrings using stack-based simulation techniqu…
半有序排列
Find the minimum number of operations to convert a permutation into a semi-ordered permutation where 1 is first and n is…
总行驶距离
Calculate the maximum distance a truck can travel using main and additional fuel tanks with controlled transfers.
最大字符串配对数目
Find the maximum number of pairs of distinct strings from an array where one string is the reverse of the other.
机器人碰撞
Robot Collisions involves simulating robot movements and handling collisions with stack-based state management.
重新放置石块
Relocate marbles to new positions in an array by simulating moves, and return sorted occupied positions.
故障键盘
Simulate typing on a faulty keyboard where pressing 'i' reverses the string, requiring careful string manipulation track…
上一个遍历的整数
This problem involves finding the last visited integer for each -1 in a given array by simulating a stack-like behavior.
循环移位后的矩阵相似检查
Determine if a matrix returns to its original state after performing cyclic row shifts k times using array and math patt…
统计已测试设备
Simulate testing devices based on battery percentages to determine how many pass the test operations in sequence.
双模幂运算
Solve the Double Modular Exponentiation problem by applying array manipulation and modular arithmetic to find good indic…
最小数字游戏
The Minimum Number Game involves simulating moves by Alice and Bob on an array, sorting elements and appending them to a…
边界上的蚂蚁
Solve the problem of counting how often an ant returns to a boundary based on the steps described in the input array.
相同分数的最大操作数目 I
Determine the maximum number of operations in an integer array where each operation must produce the same score.
超过阈值的最少操作数 II
Calculate the fewest operations to make every array element exceed a threshold using a min-heap simulation strategy effi…
将元素分配到两个数组中 I
Distribute elements from a distinct integer array into two subarrays using a sequential simulation strategy for optimal …
将元素分配到两个数组中 II
Distribute elements into two arrays based on conditions, utilizing a Binary Indexed Tree for efficient counting and simu…
执行操作标记数组中的元素
Efficiently mark elements in an array based on queries using scanning plus hash lookup to track marked indices and compu…
换水问题 II
Compute the maximum number of water bottles you can drink by simulating exchanges with step-by-step math logic.
所有球里面不同颜色的数目
Efficiently track colors on balls using array scanning and hash lookup to return the count of distinct colors after each…
候诊室中的最少椅子数
Calculate the minimum number of chairs needed in a waiting room using string simulation and event tracking efficiently.
清除数字
Remove all digits from a given string by applying a repeated operation to form the final string without digits.
找到连续赢 K 场比赛的第一位玩家
Determine which player first wins k consecutive games using array simulation logic to track ongoing victories efficientl…
找出 K 秒后拿着球的孩子
Find the child who holds the ball after k seconds of passing in a queue, considering reversals at both ends.
K 秒后第 N 个元素的值
Solve for the N-th value after K seconds by simulating array updates and using prefix sum techniques.
求出硬币游戏的赢家
In this game between Alice and Bob, players must pick coins summing to 115. Alice starts, and the goal is to determine t…
设计相邻元素求和服务
Design a service that computes sums for adjacent and diagonal elements in a 2D grid.
矩阵中的蛇
Solve the Snake in Matrix problem by simulating the snake's movement in a grid based on a series of directional commands…
K 次乘运算后的最终数组 I
Solve the problem of determining the final state of an array after multiple multiplication operations using a priority q…
K 次乘运算后的最终数组 II
Optimize the final state of an array after performing k multiplication operations with priority queues.
哈希分割字符串
Hash Divided String requires splitting a string into equal parts and combining character values modulo 26 to form a new …
找出第 K 个字符 I
Find the K-th character in a progressively built string using math and bit manipulation efficiently.
出现在屏幕上的字符串序列
Simulate Alice typing a target string with a special keyboard that appends letters one by one. Solve using string simula…
使数组元素等于零
Learn how to transform an integer array to zeros using simulation and directional selection efficiently and reliably.
移除石头游戏
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…
转换数组
Simulate operations on a circular array to return a transformed result array following specific rules.
计算字符串的镜像分数
Calculate the mirror score of a string using stack-based state management for matching letters efficiently and accuratel…
跳过交替单元格的之字形遍历
Traverse a 2D grid in a zigzag pattern while skipping alternate cells, focusing on array and matrix manipulation challen…
统计用户被提及情况
Calculate how many times each user is mentioned across MESSAGE events, accounting for offline and online statuses effici…
判断操作后字符串中的数字是否相等 I
Simulate repeated adjacent digit sums modulo 10 until two digits remain, then check whether those final digits match.
水果成篮 II
Determine the number of fruit types that remain unplaced after all allocations in the "Fruits Into Baskets II" problem.
酿造药水需要的最少总时间
This problem involves calculating the minimum time required for wizards to brew potions based on their skills and mana u…
字符串的反转度
Calculate the reverse degree of a string by simulating operations on its characters based on their positions in the alph…
移除最小数对使数组有序 I
This problem asks for the minimum number of operations to make an array non-decreasing by removing pairs of elements.
移除最小数对使数组有序 II
The problem asks to find the minimum number of operations to make an array non-decreasing by removing pairs of elements.
执行指令后的得分
Simulate a series of add and jump instructions on arrays to compute the final score efficiently using array scanning and…
移除相邻字符
This problem focuses on removing adjacent characters in a string using a stack-based approach until no more operations a…
为视频标题生成标签
Transform a video caption into a valid hashtag by simulating capitalization rules and truncation for long words efficien…
分割字符串
Partition a string into unique segments using hash table and string manipulation.
用特殊操作处理字符串 I
Simulate a series of operations on a string to transform it into the desired result using special characters.
用特殊操作处理字符串 II
Solve the problem of processing strings with special operations like '*' and '#' by simulating the rules left-to-right.