Questions
Filter by topic, difficulty, company, or study path as the app grows.
Beautiful Arrangement
Suppose you have n integers labeled 1 through n.
Maximum Good People Based on Statements
There are two types of persons: You are given a 0-indexed 2D integer array statements of size n x n that represents the statements made by n people about each other.
Search a 2D Matrix
You are given an m x n integer matrix matrix with the following two properties: Given an integer target, return true if target is in matrix or false otherwise.
Least Number of Unique Integers after K Removals
Given an array of integers arr and an integer k.
Flip Columns For Maximum Number of Equal Rows
You are given an m x n binary matrix matrix.
Maximize Active Section with Trade I
You are given a binary string s of length n, where: You can perform at most one trade to maximize the number of active sections in s.
Stone Game III
Alice and Bob continue their games with piles of stones.
Construct the Rectangle
A web developer needs to know how to design a web page's size.
Subarrays Distinct Element Sum of Squares II
You are given a 0-indexed integer array nums.
Count Subarrays of Length Three With a Condition
Given an integer array nums, return the number of subarrays of length 3 such that the sum of the first and third numbers equals exactly half of the second number.
Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Number of Subarrays That Match a Pattern II
You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1.
Number of Operations to Make Network Connected
There are n computers numbered from 0 to n - 1 connected by ethernet cables connections forming a network where connections[i] = [ai, bi] represents a connection between computers...
Find Closest Number to Zero
Given an integer array nums of size n, return the number with the value closest to 0 in nums.
Find the Longest Substring Containing Vowels in Even Counts
Given the string s, return the size of the longest substring containing each vowel an even number of times.
Sum in a Matrix
You are given a 0-indexed 2D integer array nums.
Count Submatrices With Equal Frequency of X and Y
Given a 2D character matrix grid, where grid[i][j] is either 'X', 'Y', or '.', return the number of submatrices that contain:
Count Triplets That Can Form Two Arrays of Equal XOR
Given an array of integers arr.
Single Number
Given a non-empty array of integers nums, every element appears twice except for one.
The kth Factor of n
You are given two positive integers n and k.
Knight Dialer
The chess knight has a unique movement, it may move two squares vertically and one square horizontally, or two squares horizontally and one square vertically (with both forming...
Minimize Malware Spread
You are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i][j] == 1.
Broken Calculator
There is a broken calculator that has the integer startValue on its display initially.
Maximum Swap
You are given an integer num.
Alternating Groups II
There is a circle of red and blue tiles.
Minimum Rounds to Complete All Tasks
You are given a 0-indexed integer array tasks, where tasks[i] represents the difficulty level of a task.
Sort Vowels in a String
Given a 0-indexed string s, permute s to get a new string t such that: Return the resulting string.
Longest Palindrome by Concatenating Two Letter Words
You are given an array of strings words.
Compact Object
Given an object or array obj, return a compact object.
Detect Capital
We define the usage of capitals in a word to be right when one of the following cases holds: Given a string word, return true if the usage of capitals in it is right.
Determine the Minimum Sum of a k-avoiding Array
You are given two integers, n and k.
Fibonacci Number
The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1.
Build an Array With Stack Operations
You are given an integer array target and an integer n.
Reverse Words in a String
Given an input string s, reverse the order of the words.
Count Beautiful Substrings I
You are given a string s and a positive integer k.
Most Beautiful Item for Each Query
You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively.
Minimize Result by Adding Parentheses to Expression
You are given a 0-indexed string expression of the form "<num1>+<num2>" where <num1> and <num2> represent positive integers.
Right Triangles
You are given a 2D boolean matrix grid.
Remove Trailing Zeros From a String
Given a positive integer num represented as a string, return the integer num without trailing zeros as a string.
Get Maximum in Generated Array
You are given an integer n.
Number of Different Subsequences GCDs
You are given an array nums that consists of positive integers.
Check if One String Swap Can Make Strings Equal
You are given two strings s1 and s2 of equal length.
Find the Count of Monotonic Pairs II
You are given an array of positive integers nums of length n.
Largest Substring Between Two Equal Characters
Given a string s, return the length of the longest substring between two equal characters, excluding the two characters.
Minimum Increment to Make Array Unique
You are given an integer array nums.
Is Object Empty
Given an object or an array, return if it is empty.
Determine if Two Events Have Conflict
You are given two arrays of strings that represent two inclusive events that happened on the same day, event1 and event2, where: Event times are valid 24 hours format in the form...
Maximum Score From Grid Operations
You are given a 2D matrix grid of size n x n.
Minimum Flips to Make a OR b Equal to c
Given 3 positives numbers a, b and c.
Merge Operations for Minimum Travel Time
You are given a straight road of length l km, an integer n, an integer k, and two integer arrays, position and time, each of length n.
Binary Number with Alternating Bits
Given a positive integer, check whether it has alternating bits: namely, if two adjacent bits will always have different values.
Watering Plants II
Alice and Bob want to water n plants in their garden.
Bulb Switcher
There are n bulbs that are initially off.
Check if Number is a Sum of Powers of Three
Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three.
Find Common Elements Between Two Arrays
You are given two integer arrays nums1 and nums2 of sizes n and m, respectively.
Sort the People
You are given an array of strings names, and an array heights that consists of distinct positive integers.
Minimum Time to Type Word Using Special Typewriter
There is a special typewriter with lowercase English letters 'a' to 'z' arranged in a circle with a pointer.
Height Checker
A school is trying to take an annual photo of all the students.
Pyramid Transition Matrix
You are stacking blocks to form a pyramid.
Capitalize the Title
You are given a string title consisting of one or more words separated by a single space, where each word consists of English letters.
3Sum With Multiplicity
Given an integer array arr, and an integer target, return the number of tuples i, j, k such that i < j < k and arr[i] + arr[j] + arr[k] == target.
Range Product Queries of Powers
Given a positive integer n, there exists a 0-indexed array called powers, composed of the minimum number of powers of 2 that sum to n.
Select Cells in Grid With Maximum Score
You are given a 2D matrix grid consisting of positive integers.
Maximum Amount of Money Robot Can Earn
You are given an m x n grid.
Determine Whether Matrix Can Be Obtained By Rotation
Given two n x n binary matrices mat and target, return true if it is possible to make mat equal to target by rotating mat in 90-degree increments, or false otherwise.
Distribute Money to Maximum Children
You are given an integer money denoting the amount of money (in dollars) that you have and another integer children denoting the number of children that you must distribute the...
Number of Enclaves
You are given an m x n binary matrix grid, where 0 represents a sea cell and 1 represents a land cell.
Number of Substrings With Only 1s
Given a binary string s, return the number of substrings with all characters 1's.
Minimum Number of Days to Disconnect Island
You are given an m x n binary grid grid where 1 represents land and 0 represents water.
Minimum Score of a Path Between Two Cities
You are given a positive integer n representing n cities numbered from 1 to n.
Remove Covered Intervals
Given an array intervals where intervals[i] = [li, ri] represent the interval [li, ri), remove all intervals that are covered by another interval in the list.
Maximal Rectangle
Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.
Find Eventual Safe States
There is a directed graph of n nodes with each node labeled from 0 to n - 1.
Increasing Decreasing String
You are given a string s.
Count Number of Teams
There are n soldiers standing in a line.
Maximum Points You Can Obtain from Cards
There are several cards arranged in a row, and each card has an associated number of points.
Freedom Trail
In the video game Fallout 4, the quest "Road to Freedom" requires players to reach a metal dial called the "Freedom Trail Ring" and use the dial to spell a specific keyword to...
Largest Sum of Averages
You are given an integer array nums and an integer k.
Number of Good Paths
There is a tree (i.e.
Find the Occurrence of First Almost Equal Substring
You are given two strings s and pattern.
Maximum Product of Subsequences With an Alternating Sum Equal to K
You are given an integer array nums and two integers, k and limit.
Minimum Levels to Gain More Points
You are given a binary array possible of length n.
Count the Number of Houses at a Certain Distance I
You are given three positive integers n, x, and y.
Inverse Coin Change
You are given a 1-indexed integer array numWays, where numWays[i] represents the number of ways to select a total amount i using an infinite supply of some fixed coin denominations.
Number of Ways to Form a Target String Given a Dictionary
You are given a list of strings of the same length words and a string target.
Binary String With Substrings Representing 1 To N
Given a binary string s and a positive integer n, return true if the binary representation of all the integers in the range [1, n] are substrings of s, or false otherwise.
Find Unique Binary String
Given an array of strings nums containing n unique binary strings each of length n, return a binary string of length n that does not appear in nums.
Find All Groups of Farmland
You are given a 0-indexed m x n binary matrix land where a 0 represents a hectare of forested land and a 1 represents a hectare of farmland.
Reconstruct a 2-Row Binary Matrix
Given the following details of a matrix with n columns and 2 rows : Your task is to reconstruct the matrix with upper, lower and colsum.
Evaluate the Bracket Pairs of a String
You are given a string s that contains some bracket pairs, with each pair containing a non-empty key.
The Number of Good Subsets
You are given an integer array nums.
Perfect Number
A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself.
Vowels of All Substrings
Given a string word, return the sum of the number of vowels ('a', 'e', 'i', 'o', and 'u') in every substring of word.
Array With Elements Not Equal to Average of Neighbors
You are given a 0-indexed array nums of distinct integers.
Find the K-Beauty of a Number
The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions: Given integers num and k, return the...
Spiral Matrix III
You start at the cell (rStart, cStart) of an rows x cols grid facing east.
Maximum Sum of an Hourglass
You are given an m x n integer matrix grid.
Range Sum of Sorted Subarray Sums
You are given the array nums consisting of n positive integers.
Count Substrings Starting and Ending with Given Character
You are given a string s and a character c.
Find the Integer Added to Array II
You are given two integer arrays nums1 and nums2.
Rearrange Array Elements by Sign
You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers.
Maximum Matrix Sum
You are given an n x n integer matrix.
Minimum Operations to Convert Number
You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal.
Maximum Number of Operations With the Same Score I
You are given an array of integers nums.
Remove Invalid Parentheses
Given a string s that contains parentheses and letters, remove the minimum number of invalid parentheses to make the input string valid.
Count Words Obtained After Adding a Letter
You are given two 0-indexed arrays of strings startWords and targetWords.
Smallest Range I
You are given an integer array nums and an integer k.
Number of Even and Odd Bits
You are given a positive integer n.
People Whose List of Favorite Companies Is Not a Subset of Another List
Given the array favoriteCompanies where favoriteCompanies[i] is the list of favorites companies for the ith person (indexed from 0).
Jewels and Stones
You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have.
Maximum Number of Groups Getting Fresh Donuts
There is a donuts shop that bakes donuts in batches of batchSize.
Shifting Letters II
You are given a string s of lowercase English letters and a 2D integer array shifts where shifts[i] = [starti, endi, directioni].
Count Pairs That Form a Complete Day I
Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.
Rotate String
Given two strings s and goal, return true if and only if s can become goal after some number of shifts on s.
K Inverse Pairs Array
For an integer array nums, an inverse pair is a pair of integers [i, j] where 0 <= i < j < nums.length and nums[i] > nums[j].
Count Substrings Divisible By Last Digit
You are given a string s consisting of digits.
Push Dominoes
There are n dominoes in a line, and we place each domino vertically upright.
Successful Pairs of Spells and Potions
You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the ith spell and potions[j] represents...
Compare Version Numbers
Given two version strings, version1 and version2, compare them.
Arithmetic Slices II - Subsequence
Given an integer array nums, return the number of all the arithmetic subsequences of nums.
Find the Number of Subsequences With Equal GCD
You are given an integer array nums.
Jump Game IV
Given an array of integers arr, you are initially positioned at the first index of the array.
Minimum Number of Frogs Croaking
You are given the string croakOfFrogs, which represents a combination of the string "croak" from different frogs, that is, multiple frogs can croak at the same time, so multiple...
Mark Elements on Array by Performing Queries
You are given a 0-indexed array nums of size n consisting of positive integers.
Find the Kth Largest Integer in the Array
You are given an array of strings nums and an integer k.
Maximize Active Section with Trade II
You are given a binary string s of length n, where: You can perform at most one trade to maximize the number of active sections in s.
Build a Sorted, Deduplicated List
Practice using a dynamic list (ArrayList/List) to collect, dedupe, and sort values.
Counter
Given an integer n, return a counter function.
Minimum Domino Rotations For Equal Row
In a row of dominoes, tops[i] and bottoms[i] represent the top and bottom halves of the ith domino.
Range Addition II
You are given an m x n matrix M initialized with all 0's and an array of operations ops, where ops[i] = [ai, bi] means M[x][y] should be incremented by one for all 0 <= x < ai and...
Check if The Number is Fascinating
You are given an integer n that consists of exactly 3 digits.
Handling Sum Queries After Update
You are given two 0-indexed arrays nums1 and nums2 and a 2D array queries of queries.
Maximum Ice Cream Bars
It is a sweltering summer day, and a boy wants to buy some ice cream bars.
Number of People Aware of a Secret
On day 1, one person discovers a secret.
Select K Disjoint Special Substrings
Given a string s of length n and an integer k, determine whether it is possible to select k disjoint special substrings.
Poor Pigs
There are buckets buckets of liquid, where exactly one of the buckets is poisonous.
Find the Index of the First Occurrence in a String
Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Calculate Score After Performing Instructions
You are given two arrays, instructions and values, both of size n.
Maximum XOR for Each Query
You are given a sorted array nums of n non-negative integers and an integer maximumBit.
Construct the Lexicographically Largest Valid Sequence
Given an integer n, find a sequence with elements in the range [1, n] that satisfies all of the following: The distance between two numbers on the sequence, a[i] and a[j], is the...
Best Time to Buy and Sell Stock
You are given an array prices where prices[i] is the price of a given stock on the ith day.
Maximize Palindrome Length From Subsequences
You are given two strings, word1 and word2.
Magnetic Force Between Two Balls
In the universe Earth C-137, Rick discovered a special form of magnetic force between two balls if they are put in his new invented basket.
Shifting Letters
You are given a string s of lowercase English letters and an integer array shifts of the same length.
Longest Palindrome
Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters.
Maximum Equal Frequency
Given an array nums of positive integers, return the longest possible length of an array prefix of nums, such that it is possible to remove exactly one element from this prefix so...
Concatenation of Consecutive Binary Numbers
Given an integer n, return the decimal value of the binary string formed by concatenating the binary representations of 1 to n in order, modulo 10^9 + 7.
Shortest Distance After Road Addition Queries I
You are given an integer n and a 2D integer array queries.
Longest Subsequence Repeated k Times
You are given a string s of length n, and an integer k.
Check If All 1's Are at Least Length K Places Away
Given an binary array nums and an integer k, return true if all 1's are at least k places away from each other, otherwise return false.
Find the Original Typed String I
Alice is attempting to type a specific string on her computer.
Minimum Cost of a Path With Special Roads
You are given an array start where start = [startX, startY] represents your initial position (startX, startY) in a 2D space.
Minimum Right Shifts to Sort the Array
You are given a 0-indexed array nums of length n containing distinct positive integers.
Minimum Positive Sum Subarray
You are given an integer array nums and two integers l and r.
Maximum Number of Tasks You Can Assign
You have n tasks and m workers.
Word Break II
Given a string s and a dictionary of strings wordDict, add spaces in s to construct a sentence where each word is a valid dictionary word.
Sorting the Sentence
A sentence is a list of words that are separated by a single space with no leading or trailing spaces.
K-th Smallest in Lexicographical Order
Given two integers n and k, return the kth lexicographically smallest integer in the range [1, n].
Game of Life
According to Wikipedia's article: "The Game of Life, also known simply as Life, is a cellular automaton devised by the British mathematician John Horton Conway in 1970." The board...
Minimum Cost For Tickets
You have planned some train traveling one year in advance.
Sort Integers by The Power Value
The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps: For example, the power of x = 3 is 7 because 3 needs 7 steps to...
Number of Ways to Wear Different Hats to Each Other
There are n people and 40 types of hats labeled from 1 to 40.
Largest Triangle Area
Given an array of points on the X-Y plane points where points[i] = [xi, yi], return the area of the largest triangle that can be formed by any three different points.
Clear Digits
You are given a string s.
Final Array State After K Multiplication Operations II
You are given an integer array nums, an integer k, and an integer multiplier.
K-th Nearest Obstacle Queries
There is an infinite 2D plane.
Minimum Cost to Make Arrays Identical
You are given two integer arrays arr and brr of length n, and an integer k.
Minimum Deletions to Make String Balanced
You are given a string s consisting only of characters 'a' and 'b'.
Maximum Area Rectangle With Point Constraints I
You are given an array points where points[i] = [xi, yi] represents the coordinates of a point on an infinite plane.
Find the Difference
You are given two strings s and t.
Painting the Walls
You are given two 0-indexed integer arrays, cost and time, of size n representing the costs and the time taken to paint n different walls respectively.
Minimum Path Sum
Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right, which minimizes the sum of all numbers along its path.
Meeting Rooms III
You are given an integer n.
Minimum Operations to Make the Integer Zero
You are given two integers num1 and num2.
Water and Jug Problem
You are given two jugs with capacities x liters and y liters.
Minimum Window Substring
Given two strings s and t of lengths m and n respectively, return the minimum window substring of s such that every character in t (including duplicates) is included in the window.
Nim Game
You are playing the following Nim Game with your friend: Given n, the number of stones in the heap, return true if you can win the game assuming both you and your friend play...
Number of Ways to Reach a Position After Exactly k Steps
You are given two positive integers startPos and endPos.
Palindromic Substrings
Given a string s, return the number of palindromic substrings in it.
Maximum Employees to Be Invited to a Meeting
A company is organizing a meeting and has a list of n employees, waiting to be invited.
Partition Array Into Two Arrays to Minimize Sum Difference
You are given an integer array nums of 2 * n integers.
Distribute Elements Into Two Arrays II
You are given a 1-indexed array of integers nums of length n.
Sum of All Subset XOR Totals
The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty.
Second Minimum Time to Reach Destination
A city is represented as a bi-directional connected graph with n vertices where each vertex is labeled from 1 to n (inclusive).
Minimum Average of Smallest and Largest Elements
You have an array of floating point numbers averages which is initially empty.
Count Unguarded Cells in the Grid
You are given two integers m and n representing a 0-indexed m x n grid.
Minimum Processing Time
You have a certain number of processors, each having 4 cores.
Construct Product Matrix
Given a 0-indexed 2D integer matrix grid of size n * m, we define a 0-indexed 2D matrix p of size n * m as the product matrix of grid if the following condition is met: Return the...
Statistics from a Large Sample
You are given a large sample of integers in the range [0, 255].
Number of Good Ways to Split a String
You are given a string s.
Count Nodes With the Highest Score
There is a binary tree rooted at 0 consisting of n nodes.
Longest Well-Performing Interval
We are given hours, a list of the number of hours worked per day for a given employee.
Subsets II
Given an integer array nums that may contain duplicates, return all possible subsets (the power set).
Longest Arithmetic Subsequence of Given Difference
Given an integer array arr and an integer difference, return the length of the longest subsequence in arr which is an arithmetic sequence such that the difference between adjacent...
Collect Coins in a Tree
There exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1.
Partition Array to Minimize XOR
You are given an integer array nums and an integer k.
Length of the Longest Subsequence That Sums to Target
You are given a 0-indexed array of integers nums, and an integer target.
Count of Matches in Tournament
You are given an integer n, the number of teams in a tournament that has strange rules: Return the number of matches played in the tournament until a winner is decided.
Minimum Cost Tree From Leaf Values
Given an array arr of positive integers, consider all binary trees such that: Among all possible binary trees considered, return the smallest possible sum of the values of each...
Find the Maximum Length of a Good Subsequence II
You are given an integer array nums and a non-negative integer k.
Allocate Mailboxes
Given the array houses where houses[i] is the location of the ith house along a street and an integer k, allocate k mailboxes in the street.
Circular Sentence
A sentence is a list of words that are separated by a single space with no leading or trailing spaces.
Beautiful Towers I
You are given an array heights of n integers representing the number of bricks in n consecutive towers.
Adjacent Increasing Subarrays Detection II
Given an array nums of n integers, your task is to find the maximum value of k for which there exist two adjacent subarrays of length k each, such that both subarrays are strictly...
Largest Plus Sign
You are given an integer n.
Maximum Total Importance of Roads
You are given an integer n denoting the number of cities in a country.
Count Lattice Points Inside a Circle
Given a 2D integer array circles where circles[i] = [xi, yi, ri] represents the center (xi, yi) and radius ri of the ith circle drawn on a grid, return the number of lattice...
Partition Array According to Given Pivot
You are given a 0-indexed integer array nums and an integer pivot.
Minimum Cost to Hire K Workers
There are n workers.
The Number of the Smallest Unoccupied Chair
There is a party where n friends numbered from 0 to n - 1 are attending.
Number of Ways to Assign Edge Weights II
There is an undirected tree with n nodes labeled from 1 to n, rooted at node 1.
Find Missing and Repeated Values
You are given a 0-indexed 2D integer matrix grid of size n * n with values in the range [1, n2].
Boats to Save People
You are given an array people where people[i] is the weight of the ith person, and an infinite number of boats where each boat can carry a maximum weight of limit.
Ones and Zeroes
You are given an array of binary strings strs and two integers m and n.
Count Sorted Vowel Strings
Given an integer n, return the number of strings of length n that consist only of vowels (a, e, i, o, u) and are lexicographically sorted.
Valid Word
A word is considered valid if: You are given a string word.
Verify Preorder Serialization of a Binary Tree
One way to serialize a binary tree is to use preorder traversal.
Alternating Groups III
There are some red and blue tiles arranged circularly.
Replace Elements with Greatest Element on Right Side
Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1.
Reach a Number
You are standing at position 0 on an infinite number line.
Minimum Swaps To Make Sequences Increasing
You are given two integer arrays of the same length nums1 and nums2.
Find the Substring With Maximum Cost
You are given a string s, a string chars of distinct characters and an integer array vals of the same length as chars.
Complement of Base 10 Integer
The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation.
Invalid Transactions
A transaction is possibly invalid if: You are given an array of strings transaction where transactions[i] consists of comma-separated values representing the name, time (in...
Array Nesting
You are given an integer array nums of length n where nums is a permutation of the numbers in the range [0, n - 1].
Distant Barcodes
In a warehouse, there is a row of barcodes, where the ith barcode is barcodes[i].
Minimum String Length After Removing Substrings
You are given a string s consisting only of uppercase English letters.
Minimum Cost Good Caption
You are given a string caption of length n.
Count All Valid Pickup and Delivery Options
Given n orders, each order consists of a pickup and a delivery service.
Vowel Spellchecker
Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.
Contiguous Array
Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.
Maximum Manhattan Distance After K Changes
You are given a string s consisting of the characters 'N', 'S', 'E', and 'W', where s[i] indicates movements in an infinite grid: Initially, you are at the origin (0, 0).
Maximum Subsequence Score
You are given two 0-indexed integer arrays nums1 and nums2 of equal length n and a positive integer k.
Maximum Sum of Subsequence With Non-adjacent Elements
You are given an array nums consisting of integers.
Car Pooling
There is a car with capacity empty seats.
Check if the Rectangle Corner Is Reachable
You are given two positive integers xCorner and yCorner, and a 2D array circles, where circles[i] = [xi, yi, ri] denotes a circle with center at (xi, yi) and radius ri.
Check if Array Is Sorted and Rotated
Given an array nums, return true if the array was originally sorted in non-decreasing order, then rotated some number of positions (including zero).
Binary Tree Traversals: Preorder, Inorder, Postorder
Add preorder, inorder, and postorder traversal methods to BinTree and see how each visits the same sample tree in a different order.
Count the Number of Special Characters I
You are given a string word.
Count Vowel Strings in Ranges
You are given a 0-indexed array of strings words and a 2D array of integers queries.
Sum of Mutated Array Closest to Target
Given an integer array arr and a target value target, return the integer value such that when we change all the integers larger than value in the given array to be equal to value,...
Word Search II
Given an m x n board of characters and a list of strings words, return all words on the board.
Longest Subsequence With Limited Sum
You are given an integer array nums of length n, and an integer array queries of length m.
Reverse Subarray To Maximize Array Value
You are given an integer array nums.
Maximum Number of Balloons
Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible.
Delete Columns to Make Sorted II
You are given an array of n strings strs, all of the same length.
Decode the Message
You are given the strings key and message, which represent a cipher key and a secret message, respectively.
Maximum Number of Weeks for Which You Can Work
There are n projects numbered from 0 to n - 1.
Maximum Value Sum by Placing Three Rooks I
You are given a m x n 2D array board representing a chessboard, where board[i][j] represents the value of the cell (i, j).
Maximize Spanning Tree Stability with Upgrades
You are given an integer n, representing n nodes numbered from 0 to n - 1 and a list of edges, where edges[i] = [ui, vi, si, musti]: You are also given an integer k, the maximum...
Find Center of Star Graph
There is an undirected star graph consisting of n nodes labeled from 1 to n.
Minimum Element After Replacement With Digit Sum
You are given an integer array nums.
Minimum Sum of Values by Dividing Array
You are given two arrays nums and andValues of length n and m respectively.
Find the Peaks
You are given a 0-indexed array mountain.
Least Operators to Express Number
Given a single positive integer x, we will write an expression of the form x (op1) x (op2) x (op3) x ...
Search Suggestions System
You are given an array of strings products and a string searchWord.
Most Stones Removed with Same Row or Column
On a 2D plane, we place n stones at some integer coordinate points.
Maximize the Distance Between Points on a Square
You are given an integer side, representing the edge length of a square with corners at (0, 0), (0, side), (side, 0), and (side, side) on a Cartesian plane.
Add Edges to Make Degrees of All Nodes Even
There is an undirected graph consisting of n nodes numbered from 1 to n.
Number of Ways to Stay in the Same Place After Some Steps
You have a pointer at index 0 in an array of size arrLen.
Number of Common Factors
Given two positive integers a and b, return the number of common factors of a and b.
Split the Array to Make Coprime Products
You are given a 0-indexed integer array nums of length n.
Length of Longest Subarray With at Most K Frequency
You are given an integer array nums and an integer k.
String Compression II
Run-length encoding is a string compression method that works by replacing consecutive identical characters (repeated 2 or more times) with the concatenation of the character and...
Binary Prefix Divisible By 5
You are given a binary array nums (0-indexed).
Special Array II
An array is considered special if every pair of its adjacent elements contains two numbers with different parity.
Minimum Number of Flips to Make Binary Grid Palindromic I
You are given an m x n binary matrix grid.
Alphabet Board Path
On an alphabet board, we start at position (0, 0), corresponding to character board[0][0].
Maximize Grid Happiness
You are given four integers, m, n, introvertsCount, and extrovertsCount.
Maximum Value of an Ordered Triplet II
You are given a 0-indexed integer array nums.
Unique Binary Search Trees
Given an integer n, return the number of structurally unique BST's (binary search trees) which has exactly n nodes of unique values from 1 to n.
Minimum Number of Vertices to Reach All Nodes
Given a directed acyclic graph, with n vertices numbered from 0 to n-1, and an array edges where edges[i] = [fromi, toi] represents a directed edge from node fromi to node toi.
Sort the Jumbled Numbers
You are given a 0-indexed integer array mapping which represents the mapping rule of a shuffled decimal system.
Count of Substrings Containing Every Vowel and K Consonants I
You are given a string word and a non-negative integer k.
Count the Number of Consistent Strings
You are given a string allowed consisting of distinct characters and an array of strings words.
To Lower Case
Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.
Find the Sequence of Strings Appeared on the Screen
You are given a string target.
Reverse Integer
Given a signed 32-bit integer x, return x with its digits reversed.
Minimum Cost to Make Array Equal
You are given two 0-indexed arrays nums and cost consisting each of n positive integers.
Minimum Moves to Equal Array Elements II
Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.
Maximum Number of Non-Overlapping Subarrays With Sum Equals Target
Given an array nums and an integer target, return the maximum number of non-empty non-overlapping subarrays such that the sum of values in each subarray is equal to target.
Maximum Strong Pair XOR II
You are given a 0-indexed integer array nums.
Out of Boundary Paths
There is an m x n grid with a ball.
Maximum Value of K Coins From Piles
There are n piles of coins on a table.
Minimum Number of Groups to Create a Valid Assignment
You are given a collection of numbered balls and instructed to sort them into boxes for a nearly balanced distribution.
Shuffle the Array
Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].
Reverse String
Write a function that reverses a string.
Stamping The Sequence
You are given two strings stamp and target.
Count Numbers with Unique Digits
Given an integer n, return the count of all numbers with unique digits, x, where 0 <= x < 10n.
Is Graph Bipartite?
There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1.
Append K Integers With Minimal Sum
You are given an integer array nums and an integer k.
Add Binary
Given two binary strings a and b, return their sum as a binary string.
Find Champion II
There are n teams numbered from 0 to n - 1 in a tournament; each team is also a node in a DAG.
Minimum Total Cost to Make Arrays Unequal
You are given two 0-indexed integer arrays nums1 and nums2, of equal length n.
Brace Expansion II
Under the grammar given below, strings can represent a set of lowercase words.
Number of Bit Changes to Make Two Integers Equal
You are given two positive integers n and k.
Longest Common Subpath
There is a country of n cities numbered from 0 to n - 1.
Diameter of Binary Tree
Find the length, in edges, of the longest path between any two nodes in a binary tree.
GCD Sort of an Array
You are given an integer array nums, and you can perform the following operation any number of times on nums: Return true if it is possible to sort nums in non-decreasing order...
Construct 2D Grid Matching Graph Layout
You are given a 2D integer array edges representing an undirected graph having n nodes, where edges[i] = [ui, vi] denotes an edge between nodes ui and vi.
Verifying an Alien Dictionary
In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order.
Non-decreasing Subsequences
Given an integer array nums, return all the different possible non-decreasing subsequences of the given array with at least two elements.
Find the Sum of Encrypted Integers
You are given an integer array nums containing positive integers.
Check if Array is Good
You are given an integer array nums.
Mirror Reflection
There is a special square room with mirrors on each of the four walls.
Consecutive Characters
The power of the string is the maximum length of a non-empty substring that contains only one unique character.
Parsing A Boolean Expression
A boolean expression is an expression that evaluates to either true or false.
High-Access Employees
You are given a 2D 0-indexed array of strings, access_times, with size n.
Maximum Binary String After Change
You are given a binary string binary consisting of only 0's or 1's.
Minimum Distance to Type a Word Using Two Fingers
You have a keyboard layout as shown above in the X-Y plane, where each English uppercase letter is located at some coordinate.
Smallest Missing Integer Greater Than Sequential Prefix Sum
You are given a 0-indexed array of integers nums.
Maximize the Minimum Game Score
You are given an array points of size n and an integer m.
Sort Array By Parity II
Given an array of integers nums, half of the integers in nums are odd, and the other half are even.
Count Number of Distinct Integers After Reverse Operations
You are given an array nums consisting of positive integers.
Projection Area of 3D Shapes
You are given an n x n grid where we place some 1 x 1 x 1 cubes that are axis-aligned with the x, y, and z axes.
Minimum Operations to Make a Subsequence
You are given an array target that consists of distinct integers and another integer array arr that can have duplicates.
Max Sum of a Pair With Equal Sum of Digits
You are given a 0-indexed array nums consisting of positive integers.
Distribute Candies to People
We distribute some number of candies, to a row of n = num_people people in the following way: We then give 1 candy to the first person, 2 candies to the second person, and so on...
Pass the Pillow
There are n people standing in a line labeled from 1 to n.
Maximum Distance Between a Pair of Values
You are given two non-increasing 0-indexed integer arrays nums1 and nums2.
Split Array Into Maximum Number of Subarrays
You are given an array nums consisting of non-negative integers.
Peak Index in a Mountain Array
You are given an integer mountain array arr of length n where the values increase to a peak element and then decrease.
Number of Integers With Popcount-Depth Equal to K I
You are given two integers n and k.
Maximum Count of Positive Integer and Negative Integer
Given an array nums sorted in non-decreasing order, return the maximum between the number of positive integers and the number of negative integers.
Take K of Each Character From Left and Right
You are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k.
Find the Longest Semi-Repetitive Substring
You are given a digit string s that consists of digits from 0 to 9.
Distribute Candies
Alice has n candies, where the ith candy is of type candyType[i].
Minimum Insertions to Balance a Parentheses String
Given a parentheses string s containing only the characters '(' and ')'.
Self Dividing Numbers
A self-dividing number is a number that is divisible by every digit it contains.
Number Of Ways To Reconstruct A Tree
You are given an array pairs, where pairs[i] = [xi, yi], and: Let ways be the number of rooted trees that satisfy the following conditions: Two ways are considered to be different...
Sort Colors
Given an array nums with n objects colored red, white, or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white, and blue.
Number Complement
The complement of an integer is the integer you get when you flip all the 0's to 1's and all the 1's to 0's in its binary representation.
House Robber IV
There are several consecutive houses along a street, each of which has some money inside.
Minimum Number of Valid Strings to Form Target II
You are given an array of strings words and a string target.
Maximum 69 Number
You are given a positive integer num consisting only of digits 6 and 9.
Find the Largest Palindrome Divisible by K
You are given two positive integers n and k.
Trionic Array II
You are given an integer array nums of length n.
Optimal Partition of String
Given a string s, partition the string into one or more substrings such that the characters in each substring are unique.
Maximum Number of Non-overlapping Palindrome Substrings
You are given a string s and a positive integer k.
Maximal Network Rank
There is an infrastructure of n cities with some number of roads connecting these cities.
Search a 2D Matrix II
Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix.
Minimum Recolors to Get K Consecutive Black Blocks
You are given a 0-indexed string blocks of length n, where blocks[i] is either 'W' or 'B', representing the color of the ith block.
Count Complete Substrings
You are given a string word and an integer k.
Building Boxes
You have a cubic storeroom where the width, length, and height of the room are all equal to n units.
Base 7
Given an integer num, return a string of its base 7 representation.
Nth Magical Number
A positive integer is magical if it is divisible by either a or b.
Smallest Divisible Digit Product II
You are given a string num which represents a positive integer, and an integer t.
Maximum Good Subarray Sum
You are given an array nums of length n and a positive integer k.
Surface Area of 3D Shapes
You are given an n x n grid where you have placed some 1 x 1 x 1 cubes.
Sort the Matrix Diagonally
A matrix diagonal is a diagonal line of cells starting from some cell in either the topmost row or leftmost column and going in the bottom-right direction until reaching the...
Count Valid Paths in a Tree
There is an undirected tree with n nodes labeled from 1 to n.
Maximum Size of a Set After Removals
You are given two 0-indexed integer arrays nums1 and nums2 of even length n.
Get Biggest Three Rhombus Sums in a Grid
You are given an m x n integer matrix grid.
Longest Subsequence With Decreasing Adjacent Difference
You are given an array of integers nums.
Check if Bitwise OR Has Trailing Zeros
You are given an array of positive integers nums.
Maximum Number of Eaten Apples
There is a special kind of apple tree that grows apples every day for n days.
Convert Date to Binary
You are given a string date representing a Gregorian calendar date in the yyyy-mm-dd format.
Largest Multiple of Three
Given an array of digits digits, return the largest multiple of three that can be formed by concatenating some of the given digits in any order.
Find Occurrences of an Element in an Array
You are given an integer array nums, an integer array queries, and an integer x.
Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold
Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold.
Partitioning Into Minimum Number Of Deci-Binary Numbers
A decimal number is called deci-binary if each of its digits is either 0 or 1 without any leading zeros.
Check if Grid Satisfies Conditions
You are given a 2D matrix grid of size m x n.
Word Break
Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words.
Find Maximum Non-decreasing Array Length
You are given a 0-indexed integer array nums.
Count Substrings That Can Be Rearranged to Contain a String I
You are given two strings word1 and word2.
Maximum Length of a Concatenated String with Unique Characters
You are given an array of strings arr.
Length of the Longest Alphabetical Continuous Substring
An alphabetical continuous string is a string consisting of consecutive letters in the alphabet.
Count The Number of Winning Sequences
Alice and Bob are playing a fantasy battle game consisting of n rounds where they summon one of three magical creatures each round: a Fire Dragon, a Water Serpent, or an Earth...
Maximize the Total Height of Unique Towers
You are given an array maximumHeight, where maximumHeight[i] denotes the maximum height the ith tower can be assigned.
Longest Special Path
You are given an undirected tree rooted at node 0 with n nodes numbered from 0 to n - 1, represented by a 2D array edges of length n - 1, where edges[i] = [ui, vi, lengthi]...
Find Subtree Sizes After Changes
You are given a tree rooted at node 0 that consists of n nodes numbered from 0 to n - 1.
Number of Visible People in a Queue
There are n people standing in a queue, and they numbered from 0 to n - 1 in left to right order.
Remove One Element to Make the Array Strictly Increasing
Given a 0-indexed integer array nums, return true if it can be made strictly increasing after removing exactly one element, or false otherwise.
Sorting Three Groups
You are given an integer array nums.
Subtree Inversion Sum
You are given an undirected tree rooted at node 0, with n nodes numbered from 0 to n - 1.
Delete Characters to Make Fancy String
A fancy string is a string where no three consecutive characters are equal.
Maximum Frequency of an Element After Performing Operations II
You are given an integer array nums and two integers k and numOperations.
Triangle
Given a triangle array, return the minimum path sum from top to bottom.
Course Schedule IV
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.
4Sum
Given an array nums of n integers, return an array of all the unique quadruplets [nums[a], nums[b], nums[c], nums[d]] such that: You may return the answer in any order.
Subarray Sums Divisible by K
Given an integer array nums and an integer k, return the number of non-empty subarrays that have a sum divisible by k.
Day of the Week
Given a date, return the corresponding day of the week for that date.
The Time When the Network Becomes Idle
There is a network of n servers, labeled from 0 to n - 1.
Minimum Time to Activate String
You are given a string s of length n and an integer array order, where order is a permutation of the numbers in the range [0, n - 1].
Ways to Express an Integer as Sum of Powers
Given two positive integers n and x.
Reachable Nodes In Subdivided Graph
You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1.
Jump Game
You are given an integer array nums.
Maximum White Tiles Covered by a Carpet
You are given a 2D integer array tiles where tiles[i] = [li, ri] represents that every tile j in the range li <= j <= ri is colored white.
Find Weighted Median Node in Tree
You are given an integer n and an undirected, weighted tree rooted at node 0 with n nodes numbered from 0 to n - 1.
Longest Unequal Adjacent Groups Subsequence II
You are given a string array words, and an array groups, both arrays having length n.
Length of the Longest Increasing Path
You are given a 2D array of integers coordinates of length n and an integer k, where 0 <= k < n.
Harshad Number
An integer divisible by the sum of its digits is said to be a Harshad number.
Ways to Split Array Into Three Subarrays
A split of an integer array is good if: Given nums, an array of non-negative integers, return the number of good ways to split nums.
Max Sum of Rectangle No Larger Than K
Given an m x n matrix matrix and an integer k, return the max sum of a rectangle in the matrix such that its sum is no larger than k.
Minimum Area Rectangle
You are given an array of points in the X-Y plane points where points[i] = [xi, yi].
Distinct Subsequences II
Given a string s, return the number of distinct non-empty subsequences of s.
Shortest Path with Alternating Colors
You are given an integer n, the number of nodes in a directed graph where the nodes are labeled from 0 to n - 1.
Number of Unique XOR Triplets II
You are given an integer array nums.
Maximum Sum Circular Subarray
Given a circular integer array nums of length n, return the maximum possible sum of a non-empty subarray of nums.
Maximum Score After Applying Operations on a Tree
There is an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0.
Parallel Courses II
You are given an integer n, which indicates that there are n courses labeled from 1 to n.
Match Substring After Replacement
You are given two strings s and sub.
Time Needed to Rearrange a Binary String
You are given a binary string s.
Replace Elements in an Array
You are given a 0-indexed array nums that consists of n distinct positive integers.
Strange Printer
There is a strange printer with the following two special properties: Given a string s, return the minimum number of turns the printer needed to print it.
Minimum Number of Operations to Make Array Continuous
You are given an integer array nums.
Separate Squares I
You are given a 2D integer array squares.
Maximum Strength of a Group
You are given a 0-indexed integer array nums representing the score of students in an exam.
Falling Squares
There are several squares being dropped onto the X-axis of a 2D plane.
Sum of Even Numbers After Queries
You are given an integer array nums and an array queries where queries[i] = [vali, indexi].
Find Beautiful Indices in the Given Array II
You are given a 0-indexed string s, a string a, a string b, and an integer k.
Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells.
Longest Happy Prefix
A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself).
The Skyline Problem
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance.
Count Zero Request Servers
You are given an integer n denoting the total number of servers and a 2D 0-indexed integer array logs, where logs[i] = [server_id, time] denotes that the server with id server_id...
Minimum Cost Homecoming of a Robot in a Grid
There is an m x n grid, where (0, 0) is the top-left cell and (m - 1, n - 1) is the bottom-right cell.
Lexicographically Minimum String After Removing Stars
You are given a string s.
Longest Palindrome After Substring Concatenation II
You are given two strings, s and t.
Separate Black and White Balls
There are n balls on a table, each ball has a color black or white.
Count Special Subsequences
You are given an array nums consisting of positive integers.
Find a Safe Walk Through a Grid
You are given an m x n binary matrix grid and an integer health.
Find Number of Ways to Reach the K-th Stair
You are given a non-negative integer k.
Minimum Cost of Buying Candies With Discount
A shop is selling candies at a discount.
Find the Most Common Response
You are given a 2D string array responses where each responses[i] is an array of strings representing survey responses from the ith day.
Shortest Subarray to be Removed to Make Array Sorted
Given an integer array arr, remove a subarray (can be empty) from arr such that the remaining elements in arr are non-decreasing.
Find the Longest Balanced Substring of a Binary String
You are given a binary string s consisting only of zeroes and ones.
Maximum Split of Positive Even Integers
You are given an integer finalSum.
Car Fleet
There are n cars at given miles away from the starting mile 0, traveling to reach the mile target.
Most Profitable Path in a Tree
There is an undirected tree with n nodes labeled from 0 to n - 1, rooted at node 0.
The k Strongest Values in an Array
Given an array of integers arr and an integer k.
Minimum Number of Coins to be Added
You are given a 0-indexed integer array coins, representing the values of the coins available, and an integer target.
Count Pairs Of Nodes
You are given an undirected graph defined by an integer n, the number of nodes, and a 2D integer array edges, the edges in the graph, where edges[i] = [ui, vi] indicates that...
Count Paths With the Given XOR Value
You are given a 2D integer array grid with size m x n.
Truncate Sentence
A sentence is a list of words that are separated by a single space with no leading or trailing spaces.
Number of Increasing Paths in a Grid
You are given an m x n integer matrix grid, where you can move from a cell to any adjacent cell in all 4 directions.
Check If String Is a Prefix of Array
Given a string s and an array of strings words, determine whether s is a prefix string of words.
Contains Duplicate
Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
Probability of a Two Boxes Having The Same Number of Distinct Balls
Given 2n balls of k distinct colors.
Rectangle Overlap
An axis-aligned rectangle is represented as a list [x1, y1, x2, y2], where (x1, y1) is the coordinate of its bottom-left corner, and (x2, y2) is the coordinate of its top-right...
Smallest Range II
You are given an integer array nums and an integer k.
Minimum Cost for Cutting Cake II
There is an m x n cake that needs to be cut into 1 x 1 pieces.
Next Greater Element III
Given a positive integer n, find the smallest integer which has exactly the same digits existing in the integer n and is greater in value than n.
Maximum Number of K-Divisible Components
There is an undirected tree with n nodes labeled from 0 to n - 1.
Minimum Operations to Reduce X to Zero
You are given an integer array nums and an integer x.
Count K-Reducible Numbers Less Than N
You are given a binary string s representing a number n in its binary form.
Reschedule Meetings for Maximum Free Time II
You are given an integer eventTime denoting the duration of an event.
Duplicate Zeros
Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.
Minimum Operations to Write the Letter Y on a Grid
You are given a 0-indexed n x n grid where n is odd, and grid[r][c] is 0, 1, or 2.
Minimum Number of Swaps to Make the String Balanced
You are given a 0-indexed string s of even length n.
Count Hills and Valleys in an Array
You are given a 0-indexed integer array nums.
Maximum Element After Decreasing and Rearranging
You are given an array of positive integers arr.
Find the Maximum Number of Marked Indices
You are given a 0-indexed integer array nums.
Minimum Garden Perimeter to Collect Enough Apples
In a garden represented as an infinite 2D grid, there is an apple tree planted at every integer coordinate.
Minimum Increments to Equalize Leaf Paths
You are given an integer n and an undirected tree rooted at node 0 with n nodes numbered from 0 to n - 1.
Count the Number of Beautiful Subarrays
You are given a 0-indexed integer array nums.
Maximum Number of Operations to Move Ones to the End
You are given a binary string s.
Minimum Replacements to Sort the Array
You are given a 0-indexed integer array nums.
Unique Length-3 Palindromic Subsequences
Given a string s, return the number of unique palindromes of length three that are a subsequence of s.
Alice and Bob Playing Flower Game
Alice and Bob are playing a turn-based game on a circular field surrounded by flowers.
Unique Paths
There is a robot on an m x n grid.
Minimum Number of Operations to Move All Balls to Each Box
You have n boxes.
Lexicographically Smallest String After Applying Operations
You are given a string s of even length consisting of digits from 0 to 9, and two integers a and b.
Bitwise AND of Numbers Range
Given two integers left and right that represent the range [left, right], return the bitwise AND of all numbers in this range, inclusive.
Count Paths That Can Form a Palindrome in a Tree
You are given a tree (i.e.
Minimum Steps to Convert String with Operations
You are given two strings, word1 and word2, of equal length.
Decode the Slanted Ciphertext
A string originalText is encoded using a slanted transposition cipher to a string encodedText with the help of a matrix having a fixed number of rows rows.
Add Strings
Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.
Frequencies of Shortest Supersequences
You are given an array of strings words.
Island Perimeter
You are given row x col grid representing a map where grid[i][j] = 1 represents land and grid[i][j] = 0 represents water.
Sort Array by Increasing Frequency
Given an array of integers nums, sort the array in increasing order based on the frequency of the values.
Make Lexicographically Smallest Array by Swapping Elements
You are given a 0-indexed array of positive integers nums and a positive integer limit.
Maximum Population Year
You are given a 2D integer array logs where each logs[i] = [birthi, deathi] indicates the birth and death years of the ith person.
Minimum Number of Operations to Make Array XOR Equal to K
You are given a 0-indexed integer array nums and a positive integer k.
Rings and Rods
There are n rings and each ring is either red, green, or blue.
Divide a String Into Groups of Size k
A string s can be partitioned into groups of size k using the following procedure: Note that the partition is done so that after removing the fill character from the last group...
Minimum Length of Anagram Concatenation
You are given a string s, which is known to be a concatenation of anagrams of some string t.
Maximum Number of Events That Can Be Attended
You are given an array of events where events[i] = [startDayi, endDayi].
Decode XORed Array
There is a hidden integer array arr that consists of n non-negative integers.
Longest Arithmetic Subsequence
Given an array nums of integers, return the length of the longest arithmetic subsequence in nums.
Divide Array in Sets of K Consecutive Numbers
Given an array of integers nums and a positive integer k, check whether it is possible to divide this array into sets of k consecutive numbers.
Number of Subarrays That Match a Pattern I
You are given a 0-indexed integer array nums of size n, and a 0-indexed integer array pattern of size m consisting of integers -1, 0, and 1.
Airplane Seat Assignment Probability
n passengers board an airplane with exactly n seats.
Maximum Consecutive Floors Without Special Floors
Alice manages a company and has rented some floors of a building as office space.
Minimum Total Space Wasted With K Resizing Operations
You are currently designing a dynamic array.
Minimum Operations to Exceed Threshold Value II
You are given a 0-indexed integer array nums, and an integer k.
Wildcard Matching
Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*' where: The matching should cover the entire input string (not partial).
Minimum Swaps to Arrange a Binary Grid
Given an n x n binary grid, in one step you can choose two adjacent rows of the grid and swap them.
Destroy Sequential Targets
You are given a 0-indexed array nums consisting of positive integers, representing targets on a number line.
Corporate Flight Bookings
There are n flights that are labeled from 1 to n.
Count of Sub-Multisets With Bounded Sum
You are given a 0-indexed array nums of non-negative integers, and two integers l and r.
Minimum Operations to Make a Uni-Value Grid
You are given a 2D integer grid of size m x n and an integer x.
Count Unhappy Friends
You are given a list of preferences for n friends, where n is always even.
Split With Minimum Sum
Given a positive integer num, split it into two non-negative integers num1 and num2 such that: Return the minimum possible sum of num1 and num2.
Remove All Occurrences of a Substring
Given two strings s and part, perform the following operation on s until all occurrences of the substring part are removed: Return s after removing all occurrences of part.
Maximum Prime Difference
You are given an integer array nums.
Minimum Number of Refueling Stops
A car travels from a starting position to a destination which is target miles east of the starting position.
Find the Length of the Longest Common Prefix
You are given two arrays with positive integers arr1 and arr2.
Elimination Game
You have a list arr of all integers in the range [1, n] sorted in a strictly increasing order.
Sum of Digits of String After Convert
You are given a string s consisting of lowercase English letters, and an integer k.
Numbers With Repeated Digits
Given an integer n, return the number of positive integers in the range [1, n] that have at least one repeated digit.
Count Good Triplets in an Array
You are given two 0-indexed arrays nums1 and nums2 of length n, both of which are permutations of [0, 1, ..., n - 1].
Merge Two 2D Arrays by Summing Values
You are given two 2D integer arrays nums1 and nums2.
Maximum Deletions on a String
You are given a string s consisting of only lowercase English letters.
Reverse Degree of a String
Given a string s, calculate its reverse degree.
Memoize
Given a function fn, return a memoized version of that function.
Find Number of Coins to Place in Tree Nodes
You are given an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0.
Maximum Distance in Arrays
You are given m arrays, where each array is sorted in ascending order.
Video Stitching
You are given a series of video clips from a sporting event that lasted time seconds.
Maximum Number of Removable Characters
You are given two strings s and p where p is a subsequence of s.
Super Washing Machines
You have n super washing machines on a line.
Find the Maximum Divisibility Score
You are given two integer arrays nums and divisors.
Check if All A's Appears Before All B's
Given a string s consisting of only the characters 'a' and 'b', return true if every 'a' appears before every 'b' in the string.
Find the Encrypted String
You are given a string s and an integer k.
Count Connected Components in LCM Graph
You are given an array of integers nums of size n and a positive integer threshold.
Coupon Code Validator
You are given three arrays of length n that describe the properties of n coupons: code, businessLine, and isActive.
Find the Highest Altitude
There is a biker going on a road trip.
Rotate Function
You are given an integer array nums of length n.
Minimum Absolute Difference
Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.
Number of Beautiful Integers in the Range
You are given positive integers low, high, and k.
Count Integers With Even Digit Sum
Given a positive integer num, return the number of positive integers less than or equal to num whose digit sums are even.
Sum of Good Subsequences
You are given an integer array nums.
Single Number III
Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice.
Frequency of the Most Frequent Element
The frequency of an element is the number of times it occurs in an array.
Using a Robot to Print the Lexicographically Smallest String
You are given a string s and a robot that currently holds an empty string t.
Fair Distribution of Cookies
You are given an integer array cookies, where cookies[i] denotes the number of cookies in the ith bag.
Append Characters to String to Make Subsequence
You are given two strings s and t consisting of only lowercase English letters.
Existence of a Substring in a String and Its Reverse
Given a string s, find any substring of length 2 which is also present in the reverse of s.
Fruit Into Baskets
You are visiting a farm that has a single row of fruit trees arranged from left to right.
Longest Palindrome After Substring Concatenation I
You are given two strings, s and t.
Minimum Number of Operations to Make String Sorted
You are given a string s (0-indexed).
Minimum Cuts to Divide a Circle
A valid cut in a circle can be: Some valid and invalid cuts are shown in the figures below.
Strong Password Checker II
A password is said to be strong if it satisfies all the following criteria: Given a string password, return true if it is a strong password.
Task Scheduler
You are given an array of CPU tasks, each labeled with a letter from A to Z, and a number n.
Minimum Cost to Change the Final Value of Expression
You are given a valid boolean expression as a string expression consisting of the characters '1','0','&' (bitwise AND operator),'|' (bitwise OR operator),'(', and ')'.
Longest Chunked Palindrome Decomposition
You are given a string text.
First Day Where You Have Been in All the Rooms
There are n rooms you need to visit, labeled from 0 to n - 1.
Stone Game
Alice and Bob play a game with piles of stones.
Cells with Odd Values in a Matrix
There is an m x n matrix that is initialized to all 0's.
Loud and Rich
There is a group of n people labeled from 0 to n - 1 where each person has a different amount of money and a different level of quietness.
Count Palindromic Subsequences
Given a string of digits s, return the number of palindromic subsequences of s having length 5.
Apply Operations to Make Two Strings Equal
You are given two 0-indexed binary strings s1 and s2, both of length n, and a positive integer x.
Maximum OR
You are given a 0-indexed integer array nums of length n and an integer k.
Divide Array Into Arrays With Max Difference
You are given an integer array nums of size n where n is a multiple of 3 and a positive integer k.
Largest Combination With Bitwise AND Greater Than Zero
The bitwise AND of an array nums is the bitwise AND of all integers in nums.
Replace Non-Coprime Numbers in Array
You are given an array of integers nums.
Rectangle Area
Given the coordinates of two rectilinear rectangles in a 2D plane, return the total area covered by the two rectangles.
Maximum Matching of Players With Trainers
You are given a 0-indexed integer array players, where players[i] represents the ability of the ith player.
1-bit and 2-bit Characters
We have two special characters: Given a binary array bits that ends with 0, return true if the last character must be a one-bit character.
Minimum Non-Zero Product of the Array Elements
You are given a positive integer p.
Number of Zero-Filled Subarrays
Given an integer array nums, return the number of subarrays filled with 0.
Find Maximum Number of String Pairs
You are given a 0-indexed array words consisting of distinct strings.
Calculate Money in a Piggy Bank
Hercy wants to save money for his first car.
Four Divisors
Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors.
H-Index II
Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper and citations is sorted in non-descending order,...
Remove Stones to Minimize the Total
You are given a 0-indexed integer array piles, where piles[i] represents the number of stones in the ith pile, and an integer k.
Find First and Last Position of Element in Sorted Array
Given an array of integers nums sorted in non-decreasing order, find the starting and ending position of a given target value.
Minimum Moves to Equal Array Elements
Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal.
Maximize Total Cost of Alternating Subarrays
You are given an integer array nums with length n.
As Far from Land as Possible
Given an n x n grid containing only values 0 and 1, where 0 represents water and 1 represents land, find a water cell such that its distance to the nearest land cell is maximized,...
Merge Strings Alternately
You are given two strings word1 and word2.
Number of Possible Sets of Closing Branches
There is a company with n branches across the country, some of which are connected by roads.
Map of Highest Peak
You are given an integer matrix isWater of size m x n that represents a map of land and water cells.
Next Greater Element I
The next greater element of some element x in an array is the first greater element that is to the right of x in the same array.
Transform to Chessboard
You are given an n x n binary grid board.
Minimum Increment Operations to Make Array Beautiful
You are given a 0-indexed integer array nums having length n, and an integer k.
Largest Number
Given a list of non-negative integers nums, arrange them such that they form the largest number and return it.
Minimum Length of String After Deleting Similar Ends
Given a string s consisting only of characters 'a', 'b', and 'c'.
Add Digits
Given an integer num, repeatedly add all its digits until the result has only one digit, and return it.
Minimum Time to Repair Cars
You are given an integer array ranks representing the ranks of some mechanics.
Maximum and Minimum Sums of at Most Size K Subsequences
You are given an integer array nums and a positive integer k.
Number of Ways to Arrive at Destination
You are in a city that consists of n intersections numbered from 0 to n - 1 with bi-directional roads between some intersections.
String Compression III
Given a string word, compress it using the following algorithm: Return the string comp.
Apply Operations to Maximize Frequency Score
You are given a 0-indexed integer array nums and an integer k.
Longest Palindromic Path in Graph
You are given an integer n and an undirected graph with n nodes labeled from 0 to n - 1 and a 2D array edges, where edges[i] = [ui, vi] indicates an edge between nodes ui and vi.
Max Dot Product of Two Subsequences
Given two arrays nums1 and nums2.
Maximum Performance of a Team
You are given two integers n and k and two integer arrays speed and efficiency both of length n.
Maximum Number of Achievable Transfer Requests
We have n buildings numbered from 0 to n - 1.
Minimum Operations to Make Array Equal to Target
You are given two positive integer arrays nums and target, of the same length.
Length of the Longest Valid Substring
You are given a string word and an array of strings forbidden.
Minimum Operations to Make the Array Increasing
You are given an integer array nums (0-indexed).
Minimum Array Length After Pair Removals
Given an integer array num sorted in non-decreasing order.
Minimum Falling Path Sum
Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix.
Binary Search
Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums.
Dice Roll Simulation
A die simulator generates a random number from 1 to 6 for each roll.
Minimum Changes To Make Alternating Binary String
You are given a string s consisting only of the characters '0' and '1'.
Filter Restaurants by Vegan-Friendly, Price and Distance
Given the array restaurants where restaurants[i] = [idi, ratingi, veganFriendlyi, pricei, distancei].
Find the Maximum Factor Score of Array
You are given an integer array nums.
Generate Binary Strings Without Adjacent Zeros
You are given a positive integer n.
Profitable Schemes
There is a group of n members, and a list of various crimes they could commit.
Find All People With Secret
You are given an integer n indicating there are n people numbered from 0 to n - 1.
Minimum Score by Changing Two Elements
You are given an integer array nums.
Maximum of Absolute Value Expression
Given two arrays of integers with equal lengths, return the maximum value of: |arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j| where the maximum is taken over all 0 <= i, j <...
Find X-Sum of All K-Long Subarrays I
You are given an array nums of n integers and two integers k and x.
Reduce Array Size to The Half
You are given an integer array arr.
Minimize Hamming Distance After Swap Operations
You are given two integer arrays, source and target, both of length n.
Finding the Users Active Minutes
You are given the logs for users' actions on a platform, and an integer k.
Promise Time Limit
Given an asynchronous function fn and a time t in milliseconds, return a new time limited version of the input function.
Minimize the Maximum of Two Arrays
We have two arrays arr1 and arr2 which are initially empty.
Special Binary String
Special binary strings are binary strings with the following two properties: You are given a special binary string s.
Sort Integers by The Number of 1 Bits
You are given an integer array arr.
Subsequence With the Minimum Score
You are given two strings s and t.
Prime Palindrome
Given an integer n, return the smallest prime palindrome greater than or equal to n.
Maximum Score From Removing Stones
You are playing a solitaire game with three piles of stones of sizes a, b, and c respectively.
Smallest Substring With Identical Characters I
You are given a binary string s of length n and an integer numOps.
Three Equal Parts
You are given an array arr which consists of only zeros and ones, divide the array into three non-empty parts such that all of these parts represent the same binary value.
Find the Most Competitive Subsequence
Given an integer array nums and a positive integer k, return the most competitive subsequence of nums of size k.
Restore the Array From Adjacent Pairs
There is an integer array nums that consists of n unique elements, but you have forgotten it.
Count Substrings With K-Frequency Characters I
Given a string s and an integer k, return the total number of substrings of s where at least one character appears at least k times.
Top K Frequent Elements
Given an integer array nums and an integer k, return the k most frequent elements.
Maximize Subarrays After Removing One Conflicting Pair
You are given an integer n which represents an array nums containing the numbers from 1 to n in order.
Difference Between Element Sum and Digit Sum of an Array
You are given a positive integer array nums.
Execution of All Suffix Instructions Staying in a Grid
There is an n x n grid, with the top-left cell at (0, 0) and the bottom-right cell at (n - 1, n - 1).
Perfect Rectangle
Given an array rectangles where rectangles[i] = [xi, yi, ai, bi] represents an axis-aligned rectangle.
Delete Greatest Value in Each Row
You are given an m x n matrix grid consisting of positive integers.
Maximum Product of Three Numbers
Given an integer array nums, find three numbers whose product is maximum and return the maximum product.
Minimize the Maximum Adjacent Element Difference
You are given an array of integers nums.
Earliest Finish Time for Land and Water Rides I
You are given two categories of theme park attractions: land rides and water rides.
Binary Trees With Factors
Given an array of unique integers, arr, where each integer arr[i] is strictly greater than 1.
Smallest Palindromic Rearrangement I
You are given a palindromic string s.
Kth Largest Element in an Array
Given an integer array nums and an integer k, return the kth largest element in the array.
Remove Methods From Project
You are maintaining a project that has n methods numbered from 0 to n - 1.
Check if Grid can be Cut into Sections
You are given an integer n representing the dimensions of an n x n grid, with the origin at the bottom-left corner of the grid.
Minimum Number of Steps to Make Two Strings Anagram
You are given two strings of the same length s and t.
Kids With the Greatest Number of Candies
There are n kids with candies.
Divide Two Integers
Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator.
Find Smallest Letter Greater Than Target
You are given an array of characters letters that is sorted in non-decreasing order, and a character target.
Sum Each Row of a Grid
Practice 2D array basics: nested iteration and row/column indexing.
Count Number of Trapezoids I
You are given a 2D integer array points, where points[i] = [xi, yi] represents the coordinates of the ith point on the Cartesian plane.
Letter Case Permutation
Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string.
Integer Replacement
Given a positive integer n, you can apply one of the following operations: Return the minimum number of operations needed for n to become 1.
Grumpy Bookstore Owner
There is a bookstore owner that has a store open for n minutes.
Lexicographically Smallest Generated String
You are given two strings, str1 and str2, of lengths n and m, respectively.
Sum Game
Alice and Bob take turns playing a game, with Alice starting first.
Isomorphic Strings
Given two strings s and t, determine if they are isomorphic.
Maximum Spending After Buying Items
You are given a 0-indexed m * n integer matrix values, representing the values of m * n different items in m different shops.
Number of Matching Subsequences
Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s.
Number of 1 Bits
Given a positive integer n, write a function that returns the number of set bits in its binary representation (also known as the Hamming weight).
Cheapest Flights Within K Stops
There are n cities connected by some number of flights.
Reduction Operations to Make the Array Elements Equal
Given an integer array nums, your goal is to make all elements in nums equal.
Minimum Number of Flips to Make the Binary String Alternating
You are given a binary string s.
Visit Array Positions to Maximize Score
You are given a 0-indexed integer array nums and a positive integer x.
Create Components With Same Value
There is an undirected tree with n nodes labeled from 0 to n - 1.
Excel Sheet Column Number
Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number.
Maximum Possible Number by Binary Concatenation
You are given an array of integers nums of size 3.
Count Number of Pairs With Absolute Difference K
Given an integer array nums and an integer k, return the number of pairs (i, j) where i < j such that |nums[i] - nums[j]| == k.
Partition Array into Disjoint Intervals
Given an integer array nums, partition it into two (contiguous) subarrays left and right so that: Return the length of left after such a partitioning.
Repeated DNA Sequences
The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'.
Snake in Matrix
There is a snake in an n x n matrix grid and can move in four possible directions.
Smallest Index With Equal Value
Given a 0-indexed integer array nums, return the smallest index i of nums such that i mod 10 == nums[i], or -1 if such index does not exist.
Score of Parentheses
Given a balanced parentheses string s, return the score of the string.
Equal Sum Arrays With Minimum Number of Operations
You are given two arrays of integers nums1 and nums2, possibly of different lengths.
Maximize Subarray Sum After Removing All Occurrences of One Element
You are given an integer array nums.
Make Three Strings Equal
You are given three strings: s1, s2, and s3.
Find the Minimum Amount of Time to Brew Potions
You are given two integer arrays, skill and mana, of length n and m, respectively.
Flower Planting With No Adjacent
You have n gardens, labeled from 1 to n, and an array paths where paths[i] = [xi, yi] describes a bidirectional path between garden xi to garden yi.
Count Number of Balanced Permutations
You are given a string num.
Number of Laser Beams in a Bank
Anti-theft security devices are activated inside a bank.
Determine if a Cell Is Reachable at a Given Time
You are given four integers sx, sy, fx, fy, and a non-negative integer t.
Special Permutations
You are given a 0-indexed integer array nums containing n distinct positive integers.
K-th Smallest Prime Fraction
You are given a sorted integer array arr containing 1 and prime numbers, where all the integers of arr are unique.
Continuous Subarray Sum
Given an integer array nums and an integer k, return true if nums has a good subarray or false otherwise.
Sum of Square Numbers
Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c.
Count Prefix and Suffix Pairs I
You are given a 0-indexed string array words.
Cut Off Trees for Golf Event
You are asked to cut off all the trees in a forest for a golf event.
Number of Unequal Triplets in Array
You are given a 0-indexed array of positive integers nums.
Display Table of Food Orders in a Restaurant
Given the array orders, which represents the orders that customers have done in a restaurant.
Fruits Into Baskets III
You are given two arrays of integers, fruits and baskets, each of length n, where fruits[i] represents the quantity of the ith type of fruit, and baskets[j] represents the...
Construct Smallest Number From DI String
You are given a 0-indexed string pattern of length n consisting of the characters 'I' meaning increasing and 'D' meaning decreasing.
Maximum Total Damage With Spell Casting
A magician has various spells.
Check if Two Chessboard Squares Have the Same Color
You are given two strings, coordinate1 and coordinate2, representing the coordinates of a square on an 8 x 8 chessboard.
Make Array Strictly Increasing
Given two integer arrays arr1 and arr2, return the minimum number of operations (possibly zero) needed to make arr1 strictly increasing.
Special Array With X Elements Greater Than or Equal X
You are given an array nums of non-negative integers.
Minimum ASCII Delete Sum for Two Strings
Given two strings s1 and s2, return the lowest ASCII sum of deleted characters to make two strings equal.
Longest Substring with At Least K Repeating Characters
Given a string s and an integer k, return the length of the longest substring of s such that the frequency of each character in this substring is greater than or equal to k.
House Robber II
You are a professional robber planning to rob houses along a street.
Find the Score of All Prefixes of an Array
We define the conversion array conver of an array arr as follows: We also define the score of an array arr as the sum of the values of the conversion array of arr.
Longest Nice Subarray
You are given an array nums consisting of positive integers.
Minimum Difference Between Highest and Lowest of K Scores
You are given a 0-indexed integer array nums, where nums[i] represents the score of the ith student.
Number of Lines To Write String
You are given a string s of lowercase English letters and an array widths denoting how many pixels wide each lowercase English letter is.
Minimum Number of People to Teach
On a social network consisting of m users and some friendships between users, two users can communicate with each other if they know a common language.
Average Salary Excluding the Minimum and Maximum Salary
You are given an array of unique integers salary where salary[i] is the salary of the ith employee.
Maximize Area of Square Hole in Grid
You are given the two integers, n and m and two integer arrays, hBars and vBars.
Count Asterisks
You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair.
Minimum Number of Visited Cells in a Grid
You are given a 0-indexed m x n integer matrix grid.
Minimum Number of Operations to Make Word K-Periodic
You are given a string word of size n, and an integer k such that k divides n.
XOR Operation in an Array
You are given an integer n and an integer start.
Queens That Can Attack the King
On a 0-indexed 8 x 8 chessboard, there can be multiple black queens and one white king.
Find the Winner of an Array Game
Given an integer array arr of distinct integers and an integer k.
Check if Number Has Equal Digit Count and Digit Value
You are given a 0-indexed string num of length n consisting of digits.
Pizza With 3n Slices
There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows: Given an integer array slices that represent the sizes of the pizza...
Longest Turbulent Subarray
Given an integer array arr, return the length of a maximum size turbulent subarray of arr.
Maximum Subarray Min-Product
The min-product of an array is equal to the minimum value in the array multiplied by the array's sum.
Minimum Number of Increments on Subarrays to Form a Target Array
You are given an integer array target.
Minimum Division Operations to Make Array Non Decreasing
You are given an integer array nums.
Patching Array
Given a sorted integer array nums and an integer n, add/patch elements to the array such that any number in the range [1, n] inclusive can be formed by the sum of some elements in...
Reducing Dishes
A chef has collected data on the satisfaction level of his n dishes.
Smallest Missing Non-negative Integer After Operations
You are given a 0-indexed integer array nums and an integer value.
Minimum Moves to Reach Target Score
You are playing a game with integers.
Longest Alternating Subarray
You are given a 0-indexed integer array nums.
Find the Child Who Has the Ball After K Seconds
You are given two positive integers n and k.
Rotated Digits
An integer x is a good if after rotating each digit individually by 180 degrees, we get a valid number that is different from x.
Count Increasing Quadruplets
Given a 0-indexed integer array nums of size n containing all numbers from 1 to n, return the number of increasing quadruplets.
Add Minimum Number of Rungs
You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder.
Sum of Imbalance Numbers of All Subarrays
The imbalance number of a 0-indexed integer array arr of length n is defined as the number of indices in sarr = sorted(arr) such that: Here, sorted(arr) is the function that...
Pancake Sorting
Given an array of integers arr, sort the array by performing a series of pancake flips.
Properties Graph
You are given a 2D integer array properties having dimensions n x m and an integer k.
Count Number of Special Subsequences
A sequence is special if it consists of a positive number of 0s, followed by a positive number of 1s, then a positive number of 2s.
Find Minimum Diameter After Merging Two Trees
There exist two undirected trees with n and m nodes, numbered from 0 to n - 1 and from 0 to m - 1, respectively.
Minimum Cost to Equalize Array
You are given an integer array nums and two integers cost1 and cost2.
Eliminate Maximum Number of Monsters
You are playing a video game where you are defending your city from a group of n monsters.
Minimum Time to Make Rope Colorful
Alice has n balloons arranged on a rope.
Minimum Path Cost in a Grid
You are given a 0-indexed m x n integer matrix grid consisting of distinct integers from 0 to m * n - 1.
Remove Letter To Equalize Frequency
You are given a 0-indexed string word, consisting of lowercase English letters.
Queries on a Permutation With Key
Given the array queries of positive integers between 1 and m, you have to process all queries[i] (from i=0 to i=queries.length-1) according to the following rules: Return an array...
Minimum Pair Removal to Sort Array II
Given an array nums, you can perform the following operation any number of times: Return the minimum number of operations needed to make the array non-decreasing.
Final Array State After K Multiplication Operations I
You are given an integer array nums, an integer k, and an integer multiplier.
Partition String
Given a string s, partition it into unique segments according to the following procedure: Return an array of strings segments, where segments[i] is the ith segment created.
K Radius Subarray Averages
You are given a 0-indexed array nums of n integers, and an integer k.
The Two Sneaky Numbers of Digitville
In the town of Digitville, there was a list of numbers called nums containing integers from 0 to n - 1.
Maximize Count of Distinct Primes After Split
You are given an integer array nums having length n and a 2D integer array queries where queries[i] = [idx, val].
Rank Transform of a Matrix
Given an m x n matrix, return a new matrix answer where answer[row][col] is the rank of matrix[row][col].
Where Will the Ball Fall
You have a 2-D grid of size m x n representing a box, and you have n balls.
Recover the Original Array
Alice had a 0-indexed array arr consisting of n positive integers.
First Unique Character in a String
Given a string s, find the first non-repeating character in it and return its index.
Daily Temperatures
Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to...
Count Servers that Communicate
You are given a map of a server center, represented as a m * n integer matrix grid, where 1 means that on that cell there is a server and 0 means that it is no server.
Count Ways to Build Rooms in an Ant Colony
You are an ant tasked with adding n new rooms numbered 0 to n-1 to your colony.
Construct String with Minimum Cost
You are given a string target, an array of strings words, and an integer array costs, both arrays of the same length.
Next Greater Element II
Given a circular integer array nums (i.e., the next element of nums[nums.length - 1] is nums[0]), return the next greater number for every element in nums.
Maximum Length of Subarray With Positive Product
Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive.
Subsets
Given an integer array nums of unique elements, return all possible subsets (the power set).
K-Concatenation Maximum Sum
Given an integer array arr and an integer k, modify the array by repeating it k times.
Longest String Chain
You are given an array of words where each word consists of lowercase English letters.
Minimum Skips to Arrive at Meeting On Time
You are given an integer hoursBefore, the number of hours you have to travel to your meeting.
Greatest English Letter in Upper and Lower Case
Given a string of English letters s, return the greatest English letter which occurs as both a lowercase and uppercase letter in s.
Count Collisions on a Road
There are n cars on an infinitely long road.
Smallest Value After Replacing With Sum of Prime Factors
You are given a positive integer n.
Stickers to Spell Word
We are given n different types of stickers.
Take Gifts From the Richest Pile
You are given an integer array gifts denoting the number of gifts in various piles.
Power of Four
Given an integer n, return true if it is a power of four.
Count Number of Bad Pairs
You are given a 0-indexed integer array nums.
Satisfiability of Equality Equations
You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms:...
Largest Local Values in a Matrix
You are given an n x n integer matrix grid.
Check if Point Is Reachable
There exists an infinitely large grid.
Find the Difference of Two Arrays
Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where: Note that the integers in the lists may be returned in any order.
Count Tested Devices After Test Operations
You are given a 0-indexed integer array batteryPercentages having length n, denoting the battery percentages of n 0-indexed devices.
Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome.
Maximize Distance to Closest Person
You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty...
Assign Cookies
Assume you are an awesome parent and want to give your children some cookies.
Reachable Nodes With Restrictions
There is an undirected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.
String Transformation
You are given two strings s and t of equal length n.
Making File Names Unique
Given an array of strings names of size n.
Count Good Meals
A good meal is a meal that contains exactly two different food items with a sum of deliciousness equal to a power of two.
Element Appearing More Than 25% In Sorted Array
Given an integer array sorted in non-decreasing order, there is exactly one integer in the array that occurs more than 25% of the time, return that integer.
3Sum Closest
Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target.
Find if Array Can Be Sorted
You are given a 0-indexed array of positive integers nums.
Longest Palindromic Subsequence
Given a string s, find the longest palindromic subsequence's length in s.
Count Vowel Substrings of a String
A substring is a contiguous (non-empty) sequence of characters within a string.
Paths in Matrix Whose Sum Is Divisible by K
You are given a 0-indexed m x n integer matrix grid and an integer k.
Maximum Side Length of a Square with Sum Less than or Equal to Threshold
Given a m x n matrix mat and an integer threshold, return the maximum side-length of a square with a sum less than or equal to threshold or return 0 if there is no such square.
Maximum Balanced Shipments
You are given an integer array weight of length n, representing the weights of n parcels arranged in a straight line.
Minimum Limit of Balls in a Bag
You are given an integer array nums where the ith bag contains nums[i] balls.
Product of Array Except Self
Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].
Maximize Value of Function in a Ball Passing Game
You are given an integer array receiver of length n and an integer k.
Ways to Make a Fair Array
You are given an integer array nums.
Shortest Path in a Weighted Tree
You are given an integer n and an undirected, weighted tree rooted at node 1 with n nodes numbered from 1 to n.
Decode String
Given an encoded string, return its decoded string.
Rotate Image
You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).
Count Visited Nodes in a Directed Graph
There is a directed graph consisting of n nodes numbered from 0 to n - 1 and n directed edges.
Maximum Strong Pair XOR I
You are given a 0-indexed integer array nums.
Check if All Characters Have Equal Number of Occurrences
Given a string s, return true if s is a good string, or false otherwise.
Valid Square
Given the coordinates of four points in 2D space p1, p2, p3 and p4, return true if the four points construct a square.
Integer Break
Given an integer n, break it into the sum of k positive integers, where k >= 2, and maximize the product of those integers.
Count Number of Nice Subarrays
Given an array of integers nums and an integer k.
Reformat The String
You are given an alphanumeric string s.
Minimum Operations to Make Elements Within K Subarrays Equal
You are given an integer array nums and two integers, x and k.
Max Chunks To Make Sorted
You are given an integer array arr of length n that represents a permutation of the integers in the range [0, n - 1].
Count of Integers
You are given two numeric strings num1 and num2 and two integers max_sum and min_sum.
Reveal Cards In Increasing Order
You are given an integer array deck.
Convert a Number to Hexadecimal
Given a 32-bit integer num, return a string representing its hexadecimal representation.
Maximize Consecutive Elements in an Array After Modification
You are given a 0-indexed array nums consisting of positive integers.
Incremental Memory Leak
You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks.
Find the Distance Value Between Two Arrays
Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays.
Count the Number of Substrings With Dominant Ones
You are given a binary string s.
Maximum Product of First and Last Elements of a Subsequence
You are given an integer array nums and an integer m.
Count Elements With Strictly Smaller and Greater Elements
Given an integer array nums, return the number of elements that have both a strictly smaller and a strictly greater element appear in nums.
Destination City
You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi.
Solving Questions With Brainpower
You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri].
Remove the Nth Node From the End of a List
Remove the node that sits n positions from the end of a singly-linked list, then return the list.
Escape a Large Maze
There is a 1 million by 1 million grid on an XY-plane, and the coordinates of each grid square are (x, y).
Number of Orders in the Backlog
You are given a 2D integer array orders, where each orders[i] = [pricei, amounti, orderTypei] denotes that amounti orders have been placed of type orderTypei at the price pricei.
Shortest Matching Substring
You are given a string s and a pattern string p, where p contains exactly two '*' characters.
Count Fertile Pyramids in a Land
A farmer has a rectangular grid of land with m rows and n columns that can be divided into unit cells.
Calculate Digit Sum of a String
You are given a string s consisting of digits and an integer k.
Sum of Scores of Built Strings
You are building a string s of length n one character at a time, prepending each new character to the front of the string.
Find the Middle Index in Array
Given a 0-indexed integer array nums, find the leftmost middleIndex (i.e., the smallest amongst all the possible ones).
Array of Doubled Pairs
Given an integer array of even length arr, return true if it is possible to reorder arr such that arr[2 * i + 1] = 2 * arr[2 * i] for every 0 <= i < len(arr) / 2, or false...
Count Substrings That Satisfy K-Constraint I
You are given a binary string s and an integer k.
Ways to Split Array Into Good Subarrays
You are given a binary array nums.
Peaks in Array
A peak in an array arr is an element that is greater than its previous and next element in arr.
Intersection of Two Arrays II
Given two integer arrays nums1 and nums2, return an array of their intersection.
Sum of Number and Its Reverse
Given a non-negative integer num, return true if num can be expressed as the sum of any non-negative integer and its reverse, or false otherwise.
Group the People Given the Group Size They Belong To
There are n people that are split into some unknown number of groups.
Sum of Values at Indices With K Set Bits
You are given a 0-indexed integer array nums and an integer k.
Maximum XOR Score Subarray Queries
You are given an array nums of n integers, and a 2D integer array queries of size q, where queries[i] = [li, ri].
Letter Tile Possibilities
You have n tiles, where each tile has one letter tiles[i] printed on it.
Running Sum of 1d Array
Given an array nums.
Maximize the Profit as the Salesman
You are given an integer n representing the number of houses on a number line, numbered from 0 to n - 1.
Maximum Number of Darts Inside of a Circular Dartboard
Alice is throwing n darts on a very large wall.
Defanging an IP Address
Given a valid (IPv4) IP address, return a defanged version of that IP address.
Super Ugly Number
A super ugly number is a positive integer whose prime factors are in the array primes.
Find Minimum Time to Reach Last Room II
There is a dungeon with n x m rooms arranged as a grid.
Count Pairs Of Similar Strings
You are given a 0-indexed string array words.
Get the Maximum Score
You are given two sorted arrays of distinct integers nums1 and nums2.
Decoded String at Index
You are given an encoded string s.
Count Number of Homogenous Substrings
Given a string s, return the number of homogenous substrings of s.
Container With Most Water
You are given an integer array height of length n.
Count of Range Sum
Given an integer array nums and two integers lower and upper, return the number of range sums that lie in [lower, upper] inclusive.
Type of Triangle
You are given a 0-indexed integer array nums of size 3 which can form the sides of a triangle.
Find the Number of Winning Players
You are given an integer n representing the number of players in a game and a 2D array pick where pick[i] = [xi, yi] represents that the player xi picked a ball of color yi.
Can I Win
In the "100 game" two players take turns adding, to a running total, any integer from 1 to 10.
Coordinate With Maximum Network Quality
You are given an array of network towers towers, where towers[i] = [xi, yi, qi] denotes the ith network tower with location (xi, yi) and quality factor qi.
Long Pressed Name
Your friend is typing his name into a keyboard.
Number of Sub-arrays With Odd Sum
Given an array of integers arr, return the number of subarrays with an odd sum.
Apply Operations to Maximize Score
You are given an array nums of n positive integers and an integer k.
Gray Code
An n-bit gray code sequence is a sequence of 2n integers where: Given an integer n, return any valid n-bit gray code sequence.
Average Waiting Time
There is a restaurant with a single chef.
Find Valid Pair of Adjacent Digits in String
You are given a string s consisting only of digits.
Max Pair Sum in an Array
You are given an integer array nums.
Flip String to Monotone Increasing
A binary string is monotone increasing if it consists of some number of 0's (possibly none), followed by some number of 1's (also possibly none).
Count Odd Numbers in an Interval Range
Given two non-negative integers low and high.
Number of Steps to Reduce a Number in Binary Representation to One
Given the binary representation of an integer as a string s, return the number of steps to reduce it to 1 under the following rules: It is guaranteed that you can always reach one...
Remove K Digits
Given string num representing a non-negative integer num, and an integer k, return the smallest possible integer after removing k digits from num.
Strange Printer II
There is a strange printer with the following two special requirements: You are given a m x n matrix targetGrid, where targetGrid[row][col] is the color in the position (row, col)...
Set Mismatch
You have a set of integers s, which originally contains all the numbers from 1 to n.
Non-decreasing Array
Given an array nums with n integers, your task is to check if it could become non-decreasing by modifying at most one element.
Node With Highest Edge Score
You are given a directed graph with n nodes labeled from 0 to n - 1, where each node has exactly one outgoing edge.
Sentence Similarity III
You are given two strings sentence1 and sentence2, each representing a sentence composed of words.
Sum of Numbers With Units Digit K
Given two integers num and k, consider a set of positive integers with the following properties: Return the minimum possible size of such a set, or -1 if no such set exists.
Total Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Distance Between Bus Stops
A bus has n stops numbered from 0 to n - 1 that form a circle.
N-Queens
The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.
Minimum Operations to Make Binary Array Elements Equal to One II
You are given a binary array nums.
Max Value of Equation
You are given an array points containing the coordinates of points on a 2D plane, sorted by the x-values, where points[i] = [xi, yi] such that xi < xj for all 1 <= i < j <=...
Shortest Completing Word
Given a string licensePlate and an array of strings words, find the shortest completing word in words.
Maximum AND Sum of Array
You are given an integer array nums of length n and an integer numSlots such that 2 * numSlots >= n.
Restore IP Addresses
A valid IP address consists of exactly four integers separated by single dots.
Minimum Cost Walk in Weighted Graph
There is an undirected weighted graph with n vertices labeled from 0 to n - 1.
Longest Repeating Character Replacement
You are given a string s and an integer k.
Linked List Cycle Detection
Determine whether a singly-linked list loops back on itself instead of ending in null.
Binary Tree Left Side View
Return the value of the leftmost node visible at each level of a binary tree, from top to bottom.
Move Zeroes
Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.
Find Target Indices After Sorting Array
You are given a 0-indexed integer array nums and a target element target.
Kth Distinct String in an Array
A distinct string is a string that is present only once in an array.
Equal Row and Column Pairs
Given a 0-indexed n x n integer matrix grid, return the number of pairs (ri, cj) such that row ri and column cj are equal.
Put Marbles in Bags
You have k bags.
Lexicographically Smallest String After a Swap
Given a string s containing only digits, return the lexicographically smallest string that can be obtained after swapping adjacent digits in s with the same parity at most once.
Smallest String With Swaps
You are given a string s, and an array of pairs of indices in the string pairs where pairs[i] = [a, b] indicates 2 indices(0-indexed) of the string.
Sum of Two Integers
Given two integers a and b, return the sum of the two integers without using the operators + and -.
Distinct Subsequences
Given two strings s and t, return the number of distinct subsequences of s which equals t.
Regions Cut By Slashes
An n x n grid is composed of 1 x 1 squares where each 1 x 1 square consists of a '/', '\', or blank space ' '.
Minimum Difference in Sums After Removal of Elements
You are given a 0-indexed integer array nums consisting of 3 * n elements.
XOR Queries of a Subarray
You are given an array arr of positive integers.
Summary Ranges
You are given a sorted unique integer array nums.
Maximal Score After Applying K Operations
You are given a 0-indexed integer array nums and an integer k.
Split the Array
You are given an integer array nums of even length.
Minimum Possible Integer After at Most K Adjacent Swaps On Digits
You are given a string num representing the digits of a very large integer and an integer k.
Ugly Number III
An ugly number is a positive integer that is divisible by a, b, or c.
Sort Matrix by Diagonals
You are given an n x n square matrix of integers grid.
Find Words That Can Be Formed by Characters
You are given an array of strings words and a string chars.
Minimum Time for K Connected Components
You are given an integer n and an undirected graph with n nodes labeled from 0 to n - 1.
Longest Uncommon Subsequence I
Given two strings a and b, return the length of the longest uncommon subsequence between a and b.
Maximum Number of Moves to Kill All Pawns
There is a 50 x 50 chessboard with one knight and some pawns on it.
Swap Adjacent in LR String
In a string composed of 'L', 'R', and 'X' characters, like "RXXLRXRXL", a move consists of either replacing one occurrence of "XL" with "LX", or replacing one occurrence of "RX"...
Maximum Score From Removing Substrings
You are given a string s and two integers x and y.
Number of Nodes in the Sub-Tree With the Same Label
You are given a tree (i.e.
HTML Entity Parser
HTML entity parser is the parser that takes HTML code as input and replace all the entities of the special characters by the characters itself.
Function Composition
Given an array of functions [f1, f2, f3, ..., fn], return a new function fn that is the function composition of the array of functions.
Maximum Subarray Sum with One Deletion
Given an array of integers, return the maximum sum for a non-empty subarray (contiguous elements) with at most one element deletion.
Build Array from Permutation
Given a zero-based permutation nums (0-indexed), build an array ans of the same length where ans[i] = nums[nums[i]] for each 0 <= i < nums.length and return it.
Count Submatrices With All Ones
Given an m x n binary matrix mat, return the number of submatrices that have all ones.
Find All Possible Stable Binary Arrays I
You are given 3 positive integers zero, one, and limit.
Soup Servings
You have two soups, A and B, each starting with n mL.
Maximize Win From Two Segments
There are some prizes on the X-axis.
Number of Subarrays With LCM Equal to K
Given an integer array nums and an integer k, return the number of subarrays of nums where the least common multiple of the subarray's elements is k.
Third Maximum Number
Given an integer array nums, return the third distinct maximum number in this array.
Battleships in a Board
Given an m x n matrix board where each cell is a battleship 'X' or empty '.', return the number of the battleships on board.
Maximize the Topmost Element After K Moves
You are given a 0-indexed integer array nums representing the contents of a pile, where nums[0] is the topmost element of the pile.
Number of Adjacent Elements With the Same Color
You are given an integer n representing an array colors of length n where all elements are set to 0's meaning uncolored.
Get Equal Substrings Within Budget
You are given two strings s and t of the same length and an integer maxCost.
Design Cancellable Function
Sometimes you have a long running task, and you may wish to cancel it before it completes.
Minimum Difficulty of a Job Schedule
You want to schedule a list of jobs in d days.
Divide an Array Into Subarrays With Minimum Cost I
You are given an array of integers nums of length n.
Find X-Sum of All K-Long Subarrays II
You are given an array nums of n integers and two integers k and x.
Minimum Index Sum of Two Lists
Given two arrays of strings list1 and list2, find the common strings with the least index sum.
Minimum Array Sum
You are given an integer array nums and three integers k, op1, and op2.
Beautiful Arrangement II
Given two integers n and k, construct a list answer that contains n different positive integers ranging from 1 to n and obeys the following requirement: Return the list answer.
Keep Multiplying Found Values by Two
You are given an array of integers nums.
Maximize the Confusion of an Exam
A teacher is writing a test with n true/false questions, with 'T' denoting true and 'F' denoting false.
Count Submatrices with Top-Left Element and Sum Less Than k
You are given a 0-indexed integer matrix grid and an integer k.
Student Attendance Record II
An attendance record for a student can be represented as a string where each character signifies whether the student was absent, late, or present on that day.
Sum of Squares of Special Elements
You are given a 1-indexed integer array nums of length n.
Maximum Xor Product
Given three integers a, b, and n, return the maximum value of (a XOR x) * (b XOR x) where 0 <= x < 2n.
Maximum Coins From K Consecutive Bags
There are an infinite amount of bags on a number line, one bag for each coordinate.
Check if There is a Valid Partition For The Array
You are given a 0-indexed integer array nums.
Minimize the Maximum Difference of Pairs
You are given a 0-indexed integer array nums and an integer p.
Majority Element II
Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.
Minimum Cost to Move Chips to The Same Position
We have n chips, where the position of the ith chip is position[i].
Latest Time You Can Obtain After Replacing Characters
You are given a string s representing a 12-hour format time where some of the digits (possibly none) are replaced with a "?".
Find Original Array From Doubled Array
An integer array original is transformed into a doubled array changed by appending twice the value of every element in original, and then randomly shuffling the resulting array.
Check Balanced String
You are given a string num consisting of only digits.
Largest Values From Labels
You are given n item's value and label as two integer arrays values and labels.
Find Subarrays With Equal Sum
Given a 0-indexed integer array nums, determine whether there exist two subarrays of length 2 with equal sum.
Shortest and Lexicographically Smallest Beautiful String
You are given a binary string s and a positive integer k.
Number of Unique Good Subsequences
You are given a binary string binary.
Minimize Maximum of Array
You are given a 0-indexed array nums comprising of n non-negative integers.
Make Number of Distinct Characters Equal
You are given two 0-indexed strings word1 and word2.
Remove Boxes
You are given several boxes with different colors represented by different positive numbers.
Build a Matrix With Conditions
You are given a positive integer k.
Make Sum Divisible by P
Given an array of positive integers nums, remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by p.
Double Modular Exponentiation
You are given a 0-indexed 2D array variables where variables[i] = [ai, bi, ci, mi], and an integer target.
Maximum Average Subarray I
You are given an integer array nums consisting of n elements, and an integer k.
Maximum Sum of Edge Values in a Graph
You are given an undirected connected graph of n nodes, numbered from 0 to n - 1.
Watering Plants
You want to water n plants in your garden with a watering can.
Array Partition
Given an integer array nums of 2n integers, group these integers into n pairs (a1, b1), (a2, b2), ..., (an, bn) such that the sum of min(ai, bi) for all i is maximized.
Apply Operations to an Array
You are given a 0-indexed array nums of size n consisting of non-negative integers.
Find the Median of the Uniqueness Array
You are given an integer array nums.
Remove All Adjacent Duplicates In String
You are given a string s consisting of lowercase English letters.
Maximize Number of Subsequences in a String
You are given a 0-indexed string text and another 0-indexed string pattern of length 2, both of which consist of only lowercase English letters.
Minimum Cost Path with Alternating Directions II
You are given two integers m and n representing the number of rows and columns of a grid, respectively.
Subarray With Elements Greater Than Varying Threshold
You are given an integer array nums and an integer threshold.
Count Mentions Per User
You are given an integer numberOfUsers representing the total number of users and an array events of size n x 3.
Number of Pairs of Strings With Concatenation Equal to Target
Given an array of digit strings nums and a digit string target, return the number of pairs of indices (i, j) (where i != j) such that the concatenation of nums[i] + nums[j] equals...
Longest Substring of One Repeating Character
You are given a 0-indexed string s.
Number of Beautiful Partitions
You are given a string s that consists of the digits '1' to '9' and two integers k and minLength.
Degree of an Array
Given a non-empty array of non-negative integers nums, the degree of this array is defined as the maximum frequency of any one of its elements.
Uncrossed Lines
You are given two integer arrays nums1 and nums2.
Sliding Subarray Beauty
Given an integer array nums containing n integers, find the beauty of each subarray of size k.
Determine Color of a Chessboard Square
You are given coordinates, a string that represents the coordinates of a square of the chessboard.
Count All Possible Routes
You are given an array of distinct positive integers locations where locations[i] represents the position of city i.
Substrings of Size Three with Distinct Characters
A string is good if there are no repeated characters.
Count Pairs With XOR in a Range
Given a (0-indexed) integer array nums and two integers low and high, return the number of nice pairs.
Largest Divisible Subset
Given a set of distinct positive integers nums, return the largest subset answer such that every pair (answer[i], answer[j]) of elements in this subset satisfies: If there are...
K Items With the Maximum Sum
There is a bag that consists of items, each item has a number 1, 0, or -1 written on it.
Minimum Operations to Maximize Last Elements in Arrays
You are given two 0-indexed integer arrays, nums1 and nums2, both having length n.
Minimum Cost to Reach Every Position
You are given an integer array cost of size n.
Semi-Ordered Permutation
You are given a 0-indexed permutation of n integers nums.
Check if Any Element Has Prime Frequency
You are given an integer array nums.
Find the Shortest Superstring
Given an array of strings words, return the smallest string that contains each string in words as a substring.
Teemo Attacking
Our hero Teemo is attacking an enemy Ashe with poison attacks!
Count Artifacts That Can Be Extracted
There is an n x n 0-indexed grid with some artifacts buried in it.
Minimum Operations to Make Character Frequencies Equal
You are given a string s.
Student Attendance Record I
You are given a string s representing an attendance record for a student where each character signifies whether the student was absent, late, or present on that day.
Minimum Number of Flips to Make Binary Grid Palindromic II
You are given an m x n binary matrix grid.
Find the Losers of the Circular Game
There are n friends that are playing a game.
Subarrays with K Different Integers
Given an integer array nums and an integer k, return the number of good subarrays of nums.
Minimum Seconds to Equalize a Circular Array
You are given a 0-indexed array nums containing n integers.
Minimum One Bit Operations to Make Integers Zero
Given an integer n, you must transform it into 0 using the following operations any number of times: Return the minimum number of operations to transform n into 0.
Maximum Sum of 3 Non-Overlapping Subarrays
Given an integer array nums and an integer k, find three non-overlapping subarrays of length k with maximum sum and return them.
Most Frequent Prime
You are given a m x n 0-indexed 2D matrix mat.
Maximum Value Sum by Placing Three Rooks II
You are given a m x n 2D array board representing a chessboard, where board[i][j] represents the value of the cell (i, j).
Grid Illumination
There is a 2D grid of size n x n where each cell of this grid has a lamp that is initially turned off.
Angle Between Hands of a Clock
Given two numbers, hour and minutes, return the smaller angle (in degrees) formed between the hour and the minute hand.
Two Sum II - Input Array Is Sorted
Given a 1-indexed array of integers numbers that is already sorted in non-decreasing order, find two numbers such that they add up to a specific target number.
Maximum Elegance of a K-Length Subsequence
You are given a 0-indexed 2D integer array items of length n and an integer k.
Delete Duplicate Folders in System
Due to a bug, there are many duplicate folders in a file system.
Masking Personal Information
You are given a personal information string s, representing either an email address or a phone number.
Binary Gap
Given a positive integer n, find and return the longest distance between any two adjacent 1's in the binary representation of n.
Permutations IV
Given two integers, n and k, an alternating permutation is a permutation of the first n positive integers such that no two adjacent elements are both odd or both even.
Apply Bitwise Operations to Make Strings Equal
You are given two 0-indexed binary strings s and target of the same length n.
Minimum Number of Days to Eat N Oranges
There are n oranges in the kitchen and you decided to eat some of these oranges every day as follows: You can only choose one of the actions per day.
Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining.
Count Ways to Group Overlapping Ranges
You are given a 2D integer array ranges where ranges[i] = [starti, endi] denotes that all integers between starti and endi (both inclusive) are contained in the ith range.
Jump Game II
You are given a 0-indexed array of integers nums of length n.
Find the Count of Good Integers
You are given two positive integers n and k.
Remove Adjacent Almost-Equal Characters
You are given a 0-indexed string word.
Last Moment Before All Ants Fall Out of a Plank
We have a wooden plank of the length n units.
Minimum Size Subarray Sum
Given an array of positive integers nums and a positive integer target, return the minimal length of a subarray whose sum is greater than or equal to target.
Find Xor-Beauty of Array
You are given a 0-indexed integer array nums.
Check if Strings Can be Made Equal With Operations I
You are given two strings s1 and s2, both of length 4, consisting of lowercase English letters.
Largest Component Size by Common Factor
You are given an integer array of unique positive integers nums.
Longer Contiguous Segments of Ones than Zeros
Given a binary string s, return true if the longest contiguous segment of 1's is strictly longer than the longest contiguous segment of 0's in s, or return false otherwise.
Queue Reconstruction by Height
You are given an array of people, people, which are the attributes of some people in a queue (not necessarily in order).
Single-Threaded CPU
You are given n tasks labeled from 0 to n - 1 represented by a 2D integer array tasks, where tasks[i] = [enqueueTimei, processingTimei] means that the ith task...
Check if Every Row and Column Contains All Numbers
An n x n matrix is valid if every row and every column contains all the integers from 1 to n (inclusive).
Coloring A Border
You are given an m x n integer matrix grid, and three integers row, col, and color.
Number of Valid Move Combinations On Chessboard
There is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops).
Best Team With No Conflicts
You are the manager of a basketball team.
Find the Value of the Partition
You are given a positive integer array nums.
Regular Expression Matching
Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: The matching should cover the entire input string (not partial).
Maximum Height by Stacking Cuboids
Given n cuboids where the dimensions of the ith cuboid is cuboids[i] = [widthi, lengthi, heighti] (0-indexed).
Longest Palindromic Subsequence After at Most K Operations
You are given a string s and an integer k.
Find X Value of Array I
You are given an array of positive integers nums, and a positive integer k.
Find the Maximum Achievable Number
Given two integers, num and t.
Path With Minimum Effort
You are a hiker preparing for an upcoming hike.
Smallest String With A Given Numeric Value
The numeric value of a lowercase character is defined as its position (1-indexed) in the alphabet, so the numeric value of a is 1, the numeric value of b is 2, the numeric value...
Move Pieces to Obtain a String
You are given two strings start and target, both of length n.
Minimum Cost to Convert String II
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English characters.
Minimum Operations to Make a Special Number
You are given a 0-indexed string num representing a non-negative integer.
Minimum Cost to Split an Array
You are given an integer array nums and an integer k.
Detect Cycles in 2D Grid
Given a 2D array of characters grid of size m x n, you need to find if there exists any cycle consisting of the same value in grid.
Filling Bookcase Shelves
You are given an array books where books[i] = [thicknessi, heighti] indicates the thickness and height of the ith book.
Max Area of Island
You are given an m x n binary matrix grid.
Minimum Time to Transport All Individuals
You are given n individuals at a base camp who need to cross a river to reach a destination using a single boat.
Additive Number
An additive number is a string whose digits can form an additive sequence.
K-th Symbol in Grammar
We build a table of n rows (1-indexed).
Partition Labels
You are given a string s.
Reverse Vowels of a String
Given a string s, reverse only all the vowels in the string and return it.
Maximum Number That Sum of the Prices Is Less Than or Equal to K
You are given an integer k and an integer x.
Wiggle Sort II
Given an integer array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....
Time Taken to Mark All Nodes
There exists an undirected tree with n nodes numbered 0 to n - 1.
Count Stepping Numbers in Range
Given two positive integers low and high represented as strings, find the count of stepping numbers in the inclusive range [low, high].
Number of Ways to Earn Points
There is a test that has n types of questions.
Most Frequent Even Element
Given an integer array nums, return the most frequent even element.
Plus One
You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer.
Reverse Pairs
Given an integer array nums, return the number of reverse pairs in the array.
K Divisible Elements Subarrays
Given an integer array nums and two integers k and p, return the number of distinct subarrays, which have at most k elements that are divisible by p.
Fizz Buzz
Given an integer n, return a string array answer (1-indexed) where:
Substring XOR Queries
You are given a binary string s, and a 2D integer array queries where queries[i] = [firsti, secondi].
Number of Great Partitions
You are given an array nums consisting of positive integers and an integer k.
Search in Rotated Sorted Array
There is an integer array nums sorted in ascending order (with distinct values).
Numbers At Most N Given Digit Set
Given an array of digits which is sorted in non-decreasing order.
Rank Transform of an Array
Given an array of integers arr, replace each element with its rank.
Count Beautiful Splits in an Array
You are given an array nums.
Process Restricted Friend Requests
You are given an integer n indicating the number of people in a network.
Make String a Subsequence Using Cyclic Increments
You are given two 0-indexed strings str1 and str2.
Earliest Possible Day of Full Bloom
You have n flower seeds.
Minimum Number of K Consecutive Bit Flips
You are given a binary array nums and an integer k.
Concatenated Words
Given an array of strings words (without duplicates), return all the concatenated words in the given list of words.
Find and Replace Pattern
Given a list of strings words and a string pattern, return a list of words[i] that match pattern.
Minimum Moves to Convert String
You are given a string s consisting of n characters which are either 'X' or 'O'.
Minimum Cost for Cutting Cake I
There is an m x n cake that needs to be cut into 1 x 1 pieces.
Minimum Operations to Make Array Elements Zero
You are given a 2D array queries, where queries[i] is of the form [l, r].
Minimum Removals to Balance Array
You are given an integer array nums and an integer k.
Equal Sum Grid Partition I
You are given an m x n matrix grid of positive integers.
Sum of Total Strength of Wizards
As the ruler of a kingdom, you have an army of wizards at your command.
Maximize Number of Nice Divisors
You are given a positive integer primeFactors.
Find the Number of Good Pairs II
You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively.
Find the Maximum Length of a Good Subsequence I
You are given an integer array nums and a non-negative integer k.
Number of Subsequences That Satisfy the Given Sum Condition
You are given an array of integers nums and an integer target.
Destroying Asteroids
You are given an integer mass, which represents the original mass of a planet.
Replace All ?'s to Avoid Consecutive Repeating Characters
Given a string s containing only lowercase English letters and the '?' character, convert all the '?' characters into lowercase letters such that the final string does not contain...
Sum of Absolute Differences in a Sorted Array
You are given an integer array nums sorted in non-decreasing order.
Matrix Similarity After Cyclic Shifts
You are given an m x n integer matrix mat and an integer k.
Maximum Profit from Trading Stocks with Discounts
You are given an integer n, representing the number of employees in a company.
Count Subarrays With Median K
You are given an array nums of size n consisting of distinct integers from 1 to n and a positive integer k.
Time Needed to Buy Tickets
There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the line.
Find Polygon With the Largest Perimeter
You are given an array of positive integers nums of length n.
Find the Duplicate Number
Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.
Parse Lisp Expression
You are given a string expression representing a Lisp-like expression to return the integer value of.
Remove Max Number of Edges to Keep Graph Fully Traversable
Alice and Bob have an undirected graph of n nodes and three types of edges: Given an array edges where edges[i] = [typei, ui, vi] represents a bidirectional edge of type typei...
Jump Game VI
You are given a 0-indexed integer array nums and an integer k.
Maximum Tastiness of Candy Basket
You are given an array of positive integers price where price[i] denotes the price of the ith candy and a positive integer k.
Count Special Quadruplets
Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:
Find if Path Exists in Graph
There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1 (inclusive).
Find Numbers with Even Number of Digits
Given an array nums of integers, return how many of them contain an even number of digits.
Number of Good Pairs
Given an array of integers nums, return the number of good pairs.
Sort Items by Groups Respecting Dependencies
There are n items each belonging to zero or one of m groups where group[i] is the group that the i-th item belongs to and it's equal to -1 if the i-th item belongs to no group.
Find Edges in Shortest Paths
You are given an undirected weighted graph of n nodes numbered from 0 to n - 1.
Swap For Longest Repeated Character Substring
You are given a string text.
Best Position for a Service Centre
A delivery company wants to build a new service center in a new city.
Restore The Array
A program was supposed to print an array of integers.
Maximum Number of Words You Can Type
There is a malfunctioning keyboard where some letter keys do not work.
Find Mirror Score of a String
You are given a string s.
Distribute Candies Among Children I
You are given two positive integers n and limit.
Count the Number of Good Nodes
There is an undirected tree with n nodes labeled from 0 to n - 1, and rooted at node 0.
Minimum Time to Revert Word to Initial State II
You are given a 0-indexed string word and an integer k.
Simplify Path
You are given an absolute path for a Unix-style file system, which always begins with a slash '/'.
Number of Atoms
Given a string formula representing a chemical formula, return the count of each atom.
Separate Squares II
You are given a 2D integer array squares.
Sum Multiples
Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7.
Word Ladder
A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ...
Max Increase to Keep City Skyline
There is a city composed of n x n blocks, where each block contains a single building shaped like a vertical square prism.
Alternating Groups I
There is a circle of red and blue tiles.
Find the Winner of the Circular Game
There are n friends that are playing a game.
Count Anagrams
You are given a string s containing one or more words.
Number of Employees Who Met the Target
There are n employees in a company, numbered from 0 to n - 1.
Shortest Bridge
You are given an n x n binary matrix grid where 1 represents land and 0 represents water.
Largest Number After Mutating Substring
You are given a string num, which represents a large integer.
Number of Excellent Pairs
You are given a 0-indexed positive integer array nums and a positive integer k.
Maximum Subarray Sum With Length Divisible by K
You are given an array of integers nums and an integer k.
Minimum Moves to Clean the Classroom
You are given an m x n grid classroom where a student volunteer is tasked with cleaning up litter scattered around the room.
Minimum Pair Removal to Sort Array I
Given an array nums, you can perform the following operation any number of times: Return the minimum number of operations needed to make the array non-decreasing.
Palindrome Partitioning IV
Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings.
Maximum Units on a Truck
You are assigned to put some amount of boxes onto one truck.
Divide Players Into Teams of Equal Skill
You are given a positive integer array skill of even length n where skill[i] denotes the skill of the ith player.
Number of Unique XOR Triplets I
You are given an integer array nums of length n, where nums is a permutation of the numbers in the range [1, n].
Two City Scheduling
A company is planning to interview 2n people.
Minimum Height Trees
A tree is an undirected graph in which any two vertices are connected by exactly one path.
Avoid Flood in The City
Your country has an infinite number of lakes.
Smallest K-Length Subsequence With Occurrences of a Letter
You are given a string s, an integer k, a letter letter, and an integer repetition.
Maximum Value after Insertion
You are given a very large integer n, represented as a string, and an integer digit x.
Super Egg Drop
You are given k identical eggs and you have access to a building with n floors labeled from 1 to n.
Find Lucky Integer in an Array
Given an array of integers arr, a lucky integer is an integer that has a frequency in the array equal to its value.
Minimum Substring Partition of Equal Character Frequency
Given a string s, you need to partition it into one or more balanced substrings.
Interval List Intersections
You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj].
Bitwise XOR of All Pairings
You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers.
Longest Ideal Subsequence
You are given a string s consisting of lowercase letters and an integer k.
Minimize Maximum Component Cost
You are given an undirected connected graph with n nodes labeled from 0 to n - 1 and a 2D integer array edges where edges[i] = [ui, vi, wi] denotes an undirected edge between node...
Find X Value of Array II
You are given an array of positive integers nums and a positive integer k.
Naming a Company
You are given an array of strings ideas that represents a list of names to be used in the process of naming a company.
Binary Subarrays With Sum
Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal.
Minimum Total Distance Traveled
There are some robots and factories on the X-axis.
Maximum Length of Pair Chain
You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti.
Stone Game IV
Alice and Bob take turns playing a game, with Alice starting first.
Describe the Painting
There is a long and thin painting that can be represented by a number line.
Partition to K Equal Sum Subsets
Given an integer array nums and an integer k, return true if it is possible to divide this array into k non-empty subsets whose sums are all equal.
Best Time to Buy and Sell Stock III
You are given an array prices where prices[i] is the price of a given stock on the ith day.
Minimum Cost to Reach Destination in Time
There is a country of n cities numbered from 0 to n - 1 where all the cities are connected by bi-directional roads.
Divide Array Into Equal Pairs
You are given an integer array nums consisting of 2 * n integers.
Best Time to Buy and Sell Stock with Transaction Fee
You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee.
Length of Last Word
Given a string s consisting of words and spaces, return the length of the last word in the string.
Jump Game VII
You are given a 0-indexed binary string s and two integers minJump and maxJump.
Fraction Addition and Subtraction
Given a string expression representing an expression of fraction addition and subtraction, return the calculation result in string format.
Three Divisors
Given an integer n, return true if n has exactly three positive divisors.
Fruits Into Baskets II
You are given two arrays of integers, fruits and baskets, each of length n, where fruits[i] represents the quantity of the ith type of fruit, and baskets[j] represents the...
Can Make Palindrome from Substring
You are given a string s and array queries where queries[i] = [lefti, righti, ki].
Minimum Number of Operations to Make Elements in Array Distinct
You are given an integer array nums.
Find the Largest Almost Missing Integer
You are given an integer array nums and an integer k.
Calculate Amount Paid in Taxes
You are given a 0-indexed 2D integer array brackets where brackets[i] = [upperi, percenti] means that the ith tax bracket has an upper bound of upperi and is taxed at a rate of...
Minimize OR of Remaining Elements Using Operations
You are given a 0-indexed integer array nums and an integer k.
Make Array Zero by Subtracting Equal Amounts
You are given a non-negative integer array nums.
Apply Operations on Array to Maximize Sum of Squares
You are given a 0-indexed integer array nums and a positive integer k.
Minimum Cost to Set Cooking Time
A generic microwave supports cooking times for: To set the cooking time, you push at most four digits.
Escape the Spreading Fire
You are given a 0-indexed 2D integer array grid of size m x n which represents a field.
Path Existence Queries in a Graph I
You are given an integer n representing the number of nodes in a graph, labeled from 0 to n - 1.
Shortest Subarray with Sum at Least K
Given an integer array nums and an integer k, return the length of the shortest non-empty subarray of nums with a sum of at least k.
Minimum Penalty for a Shop
You are given the customer visit log of a shop represented by a 0-indexed string customers consisting only of characters 'N' and 'Y': If the shop closes at the jth hour (0 <= j <=...
Contains Duplicate II
Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.
Count the Number of Special Characters II
You are given a string word.
Query Kth Smallest Trimmed Number
You are given a 0-indexed array of strings nums, where each string is of equal length and consists of only digits.
Find the Town Judge
In a town, there are n people labeled from 1 to n.
Maximum Number of Vowels in a Substring of Given Length
Given a string s and an integer k, return the maximum number of vowel letters in any substring of s with length k.
Find the Divisibility Array of a String
You are given a 0-indexed string word of length n consisting of digits, and a positive integer m.
Find the Number of Distinct Colors Among the Balls
You are given an integer limit and a 2D array queries of size n x 2.
Determine if Two Strings Are Close
Two strings are considered close if you can attain one from the other using the following operations: You can use the operations on either string as many times as necessary.
Reorder Routes to Make All Paths Lead to the City Zero
There are n cities numbered from 0 to n - 1 and n - 1 roads such that there is only one way to travel between two different cities (this network form a tree).
Ant on the Boundary
An ant is on a boundary.
Unique 3-Digit Even Numbers
You are given an array of digits called digits.
Total Distance Traveled
A truck has two fuel tanks.
Minimum Addition to Make Integer Beautiful
You are given two positive integers n and target.
Image Overlap
You are given two images, img1 and img2, represented as binary, square matrices of size n x n.
Count Substrings That Satisfy K-Constraint II
You are given a binary string s and an integer k.
Check if the Sentence Is Pangram
A pangram is a sentence where every letter of the English alphabet appears at least once.
Minimum White Tiles After Covering With Carpets
You are given a 0-indexed binary string floor, which represents the colors of tiles on a floor: You are also given numCarpets and carpetLen.
Word Search
Given an m x n grid of characters board and a string word, return true if word exists in the grid.
Cat and Mouse II
A game is played by a cat and a mouse named Cat and Mouse.
Convert an Array Into a 2D Array With Conditions
You are given an integer array nums.
Closest Dessert Cost
You would like to make dessert and are preparing to buy the ingredients.
Find The Original Array of Prefix Xor
You are given an integer array pref of size n.
Divisible and Non-divisible Sums Difference
You are given positive integers n and m.
Split a String Into the Max Number of Unique Substrings
Given a string s, return the maximum number of unique substrings that the given string can be split into.
Sum of Floored Pairs
Given an integer array nums, return the sum of floor(nums[i] / nums[j]) for all pairs of indices 0 <= i, j < nums.length in the array.
Longest Common Prefix of K Strings After Removal
You are given an array of strings words and an integer k.
Painting a Grid With Three Different Colors
You are given two integers m and n.
Last Substring in Lexicographical Order
Given a string s, return the last substring of s in lexicographical order.
Reverse Bits
Reverse bits of a given 32 bits unsigned integer.
Minimum Operations to Reduce an Integer to 0
You are given a positive integer n, you can do the following operation any number of times: Return the minimum number of operations to make n equal to 0.
Repeated Substring Pattern
Given a string s, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.
Maximum Number of Points with Cost
You are given an m x n integer matrix points (0-indexed).
Max Number of K-Sum Pairs
You are given an integer array nums and an integer k.
Check Knight Tour Configuration
There is a knight on an n x n chessboard.
Two Best Non-Overlapping Events
You are given a 0-indexed 2D integer array of events where events[i] = [startTimei, endTimei, valuei].
Subsequences with a Unique Middle Mode I
Given an integer array nums, find the number of subsequences of size 5 of nums with a unique middle mode.
The Number of Weak Characters in the Game
You are playing a game that contains multiple characters, and each of the characters has two main properties: attack and defense.
Power Grid Maintenance
You are given an integer c representing c power stations, each with a unique identifier id from 1 to c (1‑based indexing).
Count Symmetric Integers
You are given two positive integers low and high.
Minimum Edge Reversals So Every Node Is Reachable
There is a simple directed graph with n nodes labeled from 0 to n - 1.
Super Palindromes
Let's say a positive integer is a super-palindrome if it is a palindrome, and it is also the square of a palindrome.
Average Value of Even Numbers That Are Divisible by Three
Given an integer array nums of positive integers, return the average value of all even integers that are divisible by 3.
Longest Subarray of 1's After Deleting One Element
Given a binary array nums, you should delete one element from it.
Find the Number of Possible Ways for an Event
You are given three integers n, x, and y.
Count Beautiful Substrings II
You are given a string s and a positive integer k.
Maximum Area of Longest Diagonal Rectangle
You are given a 2D 0-indexed integer array dimensions.
Maximum Nesting Depth of Two Valid Parentheses Strings
A string is a valid parentheses string (denoted VPS) if and only if it consists of "(" and ")" characters only, and: We can similarly define the nesting depth depth(S) of any VPS...
Maximum Odd Binary Number
You are given a binary string s that contains at least one '1'.
Bitwise ORs of Subarrays
Given an integer array arr, return the number of distinct bitwise ORs of all the non-empty subarrays of arr.
Process String with Special Operations I
You are given a string s consisting of lowercase English letters and the special characters: *, #, and %.
Shortest Path Visiting All Nodes
You have an undirected, connected graph of n nodes labeled from 0 to n - 1.
Reschedule Meetings for Maximum Free Time I
You are given an integer eventTime denoting the duration of an event, where the event occurs from time t = 0 to time t = eventTime.
Time Needed to Inform All Employees
A company has n employees with a unique ID for each employee from 0 to n - 1.
Minimum Time Visiting All Points
On a 2D plane, there are n points with integer coordinates points[i] = [xi, yi].
Cat and Mouse
A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns.
Minimum Deletions to Make Character Frequencies Unique
A string s is called good if there are no two different characters in s that have the same frequency.
Longest Strictly Increasing or Strictly Decreasing Subarray
You are given an array of integers nums.
Gas Station
There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].
Minimum Money Required Before Transactions
You are given a 0-indexed 2D integer array transactions, where transactions[i] = [costi, cashbacki].
Maximum Score Words Formed by Letters
Given a list of words, list of single letters (might be repeating) and score of every character.
Substring with Concatenation of All Words
You are given a string s and an array of strings words.
Replace Question Marks in String to Minimize Its Value
You are given a string s.
Minimum Operations to Make Median of Array Equal to K
You are given an integer array nums and a non-negative integer k.
Process Tasks Using Servers
You are given two 0-indexed integer arrays servers and tasks of lengths n and m respectively.
Maximum XOR of Two Numbers in an Array
Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n.
Count the Number of Arrays with K Matching Adjacent Elements
You are given three integers n, m, k.
Maximum Beauty of an Array After Applying Operation
You are given a 0-indexed array nums and a non-negative integer k.
Sliding Puzzle
On an 2 x 3 board, there are five tiles labeled from 1 to 5, and an empty square represented by 0.
Arithmetic Slices
An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.
Lexicographically Smallest Equivalent String
You are given two strings of the same length s1 and s2 and a string baseStr.
Maximum Score of Non-overlapping Intervals
You are given a 2D integer array intervals, where intervals[i] = [li, ri, weighti].
Minimum Increments for Target Multiples in an Array
You are given two arrays, nums and target.
H-Index
Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher's h-index.
Number of Ways Where Square of Number Is Equal to Product of Two Numbers
Given two arrays of integers nums1 and nums2, return the number of triplets formed (type 1 and type 2) under the following rules:
Pascal's Triangle II
Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle.
Majority Element
Given an array nums of size n, return the majority element.
Swim in Rising Water
You are given an n x n integer matrix grid where each value grid[i][j] represents the elevation at that point (i, j).
Minimum Deletions to Make Array Beautiful
You are given a 0-indexed integer array nums.
Minimum Edge Weight Equilibrium Queries in a Tree
There is an undirected tree with n nodes labeled from 0 to n - 1.
Find the Kth Smallest Sum of a Matrix With Sorted Rows
You are given an m x n matrix mat that has its rows sorted in non-decreasing order and an integer k.
Number of Burgers with No Waste of Ingredients
Given two integers tomatoSlices and cheeseSlices.
Number of Closed Islands
Given a 2D grid consists of 0s (land) and 1s (water).
Maximum Number of Visible Points
You are given an array points, an integer angle, and your location, where location = [posx, posy] and points[i] = [xi, yi] both denote integral coordinates on the X-Y plane.
Minimum Time to Visit Disappearing Nodes
There is an undirected graph of n nodes.
Largest Magic Square
A k x k magic square is a k x k grid filled with integers such that every row sum, every column sum, and both diagonal sums are all equal.
Minimum Genetic Mutation
A gene string can be represented by an 8-character long string, with choices from 'A', 'C', 'G', and 'T'.
01 Matrix
Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.
Global and Local Inversions
You are given an integer array nums of length n which represents a permutation of all the integers in the range [0, n - 1].
Self Crossing
You are given an array of integers distance.
Maximum Number of Events That Can Be Attended II
You are given an array of events where events[i] = [startDayi, endDayi, valuei].
Neighboring Bitwise XOR
A 0-indexed array derived with length n is derived by computing the bitwise XOR (⊕) of adjacent values in a binary array original of length n.
Frog Jump
A frog is crossing a river.
Pacific Atlantic Water Flow
There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean.
Vowels Game in a String
Alice and Bob are playing a game on a string.
Reward Top K Students
You are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively.
Distribute Elements Into Two Arrays I
You are given a 1-indexed array of distinct integers nums of length n.
Delete Columns to Make Sorted III
You are given an array of n strings strs, all of the same length.
Zigzag Grid Traversal With Skip
You are given an m x n 2D array grid of positive integers.
Get Watched Videos by Your Friends
There are n people, each person has a unique id between 0 and n-1.
Zigzag Conversion
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) And...
Minimum Time to Reach Destination in Directed Graph
You are given an integer n and a directed graph with n nodes labeled from 0 to n - 1.
Alert Using Same Key-Card Three or More Times in a One Hour Period
Employees at a company use key-cards to unlock office doors.
Interleaving String
Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2.
Minimum Operations to Make the Array K-Increasing
You are given a 0-indexed array arr consisting of n positive integers, and a positive integer k.
Maximum Number of Words Found in Sentences
A sentence is a list of words that are separated by a single space with no leading or trailing spaces.
Lexicographically Smallest Palindrome
You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it.
Reorder Data in Log Files
You are given an array of logs.
Minimum Cost to Connect Two Groups of Points
You are given two groups of points where the first group has size1 points, the second group has size2 points, and size1 >= size2.
Number of Arithmetic Triplets
You are given a 0-indexed, strictly increasing integer array nums and a positive integer diff.
Check if Word Equals Summation of Two Words
The letter value of a letter is its position in the alphabet starting from 0 (i.e.
Find All Good Indices
You are given a 0-indexed integer array nums of size n and a positive integer k.
Count Primes
Given an integer n, return the number of prime numbers that are strictly less than n.
Alternating Digit Sum
You are given a positive integer n.
Maximum Sum of Almost Unique Subarray
You are given an integer array nums and two positive integers m and k.
Triples with Bitwise AND Equal To Zero
Given an integer array nums, return the number of AND triples.
Number of Times Binary String Is Prefix-Aligned
You have a 1-indexed binary string of length n where all the bits are 0 initially.
Redundant Connection II
In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has...
Distinct Echo Substrings
Return the number of distinct non-empty substrings of text that can be written as the concatenation of some string with itself (i.e.
Find the Lexicographically Smallest Valid Sequence
You are given two strings word1 and word2.
Power of Heroes
You are given a 0-indexed integer array nums representing the strength of some heroes.
Find Maximum Number of Non Intersecting Substrings
You are given a string word.
Longest Common Suffix Queries
You are given two arrays of strings wordsContainer and wordsQuery.
Maximum Points Inside the Square
You are given a 2D array points and a string s where, points[i] represents the coordinates of point i, and s[i] represents the tag of point i.
Movement of Robots
Some robots are standing on an infinite number line with their initial coordinates given by a 0-indexed integer array nums and will start moving once given the command to move.
Minimum Cost to Divide Array Into Subarrays
You are given two integer arrays, nums and cost, of the same size, and an integer k.
Minimum Rectangles to Cover Points
You are given a 2D integer array points, where points[i] = [xi, yi].
Adding Two Negabinary Numbers
Given two numbers arr1 and arr2 in base -2, return the result of adding them together.
Shortest Palindrome
You are given a string s.
Maximum Number of Robots Within Budget
You have n robots.
Next Greater Numerically Balanced Number
An integer x is numerically balanced if for every digit d in the number x, there are exactly d occurrences of that digit in x.
Knight Probability in Chessboard
On an n x n chessboard, a knight starts at the cell (row, column) and attempts to make exactly k moves.
Minimum Number of Moves to Make Palindrome
You are given a string s consisting only of lowercase English letters.
Apply Operations to Make All Array Elements Equal to Zero
You are given a 0-indexed integer array nums and a positive integer k.
Zero Array Transformation IV
You are given an integer array nums of length n and a 2D array queries, where queries[i] = [li, ri, vali].
Find Critical and Pseudo-Critical Edges in Minimum Spanning Tree
Given a weighted undirected connected graph with n vertices numbered from 0 to n - 1, and an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional and weighted...
Validate Binary Tree Nodes
You have n binary tree nodes numbered from 0 to n - 1 where node i has two children leftChild[i] and rightChild[i], return true if and only if all the given nodes form exactly one...
Find the Number of Subarrays Where Boundary Elements Are Maximum
You are given an array of positive integers nums.
Greatest Sum Divisible by Three
Given an integer array nums, return the maximum possible sum of elements of the array such that it is divisible by three.
Transform Array by Parity
You are given an integer array nums.
Longest Palindromic Substring
Given a string s, return the longest palindromic substring in s.
Find the Longest Equal Subarray
You are given a 0-indexed integer array nums and an integer k.
Contains Duplicate III
You are given an integer array nums and two integers indexDiff and valueDiff.
Maximum Number of Points From Grid Queries
You are given an m x n integer matrix grid and an array queries of size k.
Hash Divided String
You are given a string s of length n and an integer k, where n is a multiple of k.
Rearrange Array to Maximize Prefix Score
You are given a 0-indexed integer array nums.
Lucky Numbers in a Matrix
Given an m x n matrix of distinct numbers, return all lucky numbers in the matrix in any order.
Word Subsets
You are given two string arrays words1 and words2.
Maximum Total Beauty of the Gardens
Alice is a caretaker of n gardens and she wants to plant flowers to maximize the total beauty of all her gardens.
Special Positions in a Binary Matrix
Given an m x n binary matrix mat, return the number of special positions in mat.
Minimum Equal Sum of Two Arrays After Replacing Zeros
You are given two arrays nums1 and nums2 consisting of positive integers.
Perfect Squares
Given an integer n, return the least number of perfect square numbers that sum to n.
Sliding Window Maximum
You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right.
Candy
There are n children standing in a line.
Shortest Distance to a Character
Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the closest...
Zero Array Transformation I
You are given an integer array nums of length n and a 2D array queries, where queries[i] = [li, ri].
Minimum Number of Flips to Convert Binary Matrix to Zero Matrix
Given a m x n binary matrix mat.
Length of Longest V-Shaped Diagonal Segment
You are given a 2D integer matrix grid of size n x m, where each element is either 0, 1, or 2.
Split Array into Fibonacci Sequence
You are given a string of digits num, such as "123456579".
Make The String Great
Given a string s of lower and upper case English letters.
Find the Width of Columns of a Grid
You are given a 0-indexed m x n integer matrix grid.
Count Square Sum Triples
A square triple (a,b,c) is a triple where a, b, and c are integers and a2 + b2 = c2.
Basic Calculator
Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation.
The Number of Full Rounds You Have Played
You are participating in an online chess tournament.
Frog Position After T Seconds
Given an undirected tree consisting of n vertices numbered from 1 to n.
Find Most Frequent Vowel and Consonant
You are given a string s consisting of lowercase English letters ('a' to 'z').
Minimum Weighted Subgraph With the Required Paths
You are given an integer n denoting the number of nodes of a weighted directed graph.
Finding 3-Digit Even Numbers
You are given an integer array digits, where each element is a digit.
Length of Longest Fibonacci Subsequence
A sequence x1, x2, ..., xn is Fibonacci-like if: Given a strictly increasing array arr of positive integers forming a sequence, return the length of the longest Fibonacci-like...
Minimum Number of Moves to Seat Everyone
There are n availabe seats and n students standing in a room.
Minimum Number of Operations to Make Array Empty
You are given a 0-indexed array nums consisting of positive integers.
Egg Drop With 2 Eggs and N Floors
You are given two identical eggs and you have access to a building with n floors labeled from 1 to n.
Detect Pattern of Length M Repeated K or More Times
Given an array of positive integers arr, find a pattern of length m that is repeated k or more times.
Minimum Numbers of Function Calls to Make Target Array
You are given an integer array nums.
Flood Fill
You are given an image represented by an m x n grid of integers image, where image[i][j] represents the pixel value of the image.
Number of Integers With Popcount-Depth Equal to K II
You are given an integer array nums.
Sqrt(x)
Given a non-negative integer x, return the square root of x rounded down to the nearest integer.
Largest Merge Of Two Strings
You are given two strings word1 and word2.
Minimum Number of Arrows to Burst Balloons
There are some spherical balloons taped onto a flat wall that represents the XY-plane.
Array Reduce Transformation
Given an integer array nums, a reducer function fn, and an initial value init, return the final result obtained by executing the fn function on each element of the array,...
Maximum Compatibility Score Sum
There is a survey that consists of n questions where each question's answer is either 0 (no) or 1 (yes).
Longest Special Path II
You are given an undirected tree rooted at node 0, with n nodes numbered from 0 to n - 1.
Dungeon Game
The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon.
Earliest Second to Mark Indices II
You are given two 1-indexed integer arrays, nums and, changeIndices, having lengths n and m, respectively.
Maximum Product of Two Digits
You are given a positive integer n.
Thousand Separator
Given an integer n, add a dot (".") as the thousands separator and return it in string format.
Maximum Score After Splitting a String
Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e.
Minimum Elements to Add to Form a Given Sum
You are given an integer array nums and two integers limit and goal.
Minimum Operations to Make All Array Elements Equal
You are given an array nums consisting of positive integers.
Count Unreachable Pairs of Nodes in an Undirected Graph
You are given an integer n.
Shortest Distance to Target String in a Circular Array
You are given a 0-indexed circular string array words and a string target.
Pascal's Triangle
Given an integer numRows, return the first numRows of Pascal's triangle.
Find the Closest Palindrome
Given a string n representing an integer, return the closest integer (not including itself), which is a palindrome.
Find the Maximum Sequence Value of Array
You are given an integer array nums and a positive integer k.
Minimum Number of Seconds to Make Mountain Height Zero
You are given an integer mountainHeight denoting the height of a mountain.
Heaters
Winter is coming!
Sell Diminishing-Valued Colored Balls
You have an inventory of different colored balls, and there is a customer that wants orders balls of any color.
The Number of Beautiful Subsets
You are given an array nums of positive integers and a positive integer k.
Minesweeper
Let's play the minesweeper game (Wikipedia, online game)!
Frog Jump II
You are given a 0-indexed integer array stones sorted in strictly increasing order representing the positions of stones in a river.
Minimum Lines to Represent a Line Chart
You are given a 2D integer array stockPrices where stockPrices[i] = [dayi, pricei] indicates the price of the stock on day dayi is pricei.
Convert Integer to the Sum of Two No-Zero Integers
No-Zero integer is a positive integer that does not contain any 0 in its decimal representation.
Single Element in a Sorted Array
You are given a sorted array consisting of only integers where every element appears exactly twice, except for one element which appears exactly once.
Race Car
Your car starts at position 0 and speed +1 on an infinite number line.
Find Longest Special Substring That Occurs Thrice II
You are given a string s that consists of lowercase English letters.
Find the Minimum Area to Cover All Ones II
You are given a 2D binary array grid.
Search in Rotated Sorted Array II
There is an integer array nums sorted in non-decreasing order (not necessarily with distinct values).
Minimum Amount of Time to Collect Garbage
You are given a 0-indexed array of strings garbage where garbage[i] represents the assortment of garbage at the ith house.
Find Resultant Array After Removing Anagrams
You are given a 0-indexed string array words, where words[i] consists of lowercase English letters.
Find Minimum in Rotated Sorted Array II
Suppose an array of length n sorted in ascending order is rotated between 1 and n times.
Counter II
Write a function createCounter.
Maximize Happiness of Selected Children
You are given an array happiness of length n, and a positive integer k.
Maximum Product of Word Lengths
Given a string array words, return the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters.
Valid Boomerang
Given an array points where points[i] = [xi, yi] represents a point on the X-Y plane, return true if these points are a boomerang.
Surrounded Regions
You are given an m x n matrix board containing letters 'X' and 'O', capture regions that are surrounded: To capture a surrounded region, replace all 'O's with 'X's in-place within...
Prime In Diagonal
You are given a 0-indexed two-dimensional integer array nums.
Palindrome Rearrangement Queries
You are given a 0-indexed string s having an even length n.
Maximum Number of Coins You Can Get
There are 3n piles of coins of varying size, you and your friends will take piles of coins as follows: Given an array of integers piles where piles[i] is the number of coins in...
Diagonal Traverse
Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order.
Best Time to Buy and Sell Stock II
You are given an integer array prices where prices[i] is the price of a given stock on the ith day.
Minimum Deletions to Make String K-Special
You are given a string word and an integer k.
Minimum Sum of Mountain Triplets I
You are given a 0-indexed array nums of integers.
Maximum Difference Between Adjacent Elements in a Circular Array
Given a circular array nums, find the maximum absolute difference between adjacent elements.
Largest Time for Given Digits
Given an array arr of 4 digits, find the latest 24-hour time that can be made using each digit exactly once.
Minimum Operations to Make Binary Array Elements Equal to One I
You are given a binary array nums.
Buddy Strings
Given two strings s and goal, return true if you can swap two letters in s so the result is equal to goal, otherwise, return false.
Maximum Average Pass Ratio
There is a school that has classes of students and each class will be having a final exam.
Ransom Note
Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.
Number of Ways to Buy Pens and Pencils
You are given an integer total indicating the amount of money you have.
Count Days Without Meetings
You are given a positive integer days representing the total number of days an employee is available for work (starting from day 1).
Keyboard Row
Given an array of strings words, return the words that can be typed using letters of the alphabet on only one row of American keyboard like the image below.
Minimum Value to Get Positive Step by Step Sum
Given an array of integers nums, you start with an initial positive value startValue.
Partition String Into Minimum Beautiful Substrings
Given a binary string s, partition the string into one or more substrings such that each substring is beautiful.
Find Minimum Time to Reach Last Room I
There is a dungeon with n x m rooms arranged as a grid.
Minimum Initial Energy to Finish Tasks
You are given an array tasks where tasks[i] = [actuali, minimumi]: For example, if the task is [10, 12] and your current energy is 11, you cannot start this task.
Maximum Star Sum of a Graph
There is an undirected graph consisting of n nodes numbered from 0 to n - 1.
Minimum Operations to Make the Array Alternating
You are given a 0-indexed array nums consisting of n positive integers.
Construct Target Array With Multiple Sums
You are given an array target of n integers.
House Robber
You are a professional robber planning to rob houses along a street.
Find the Key of the Numbers
You are given three positive integers num1, num2, and num3.
Removing Minimum Number of Magic Beans
You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag.
Maximize Score After N Operations
You are given nums, an array of positive integers of size 2 * n.
Partition Array Such That Maximum Difference Is K
You are given an integer array nums and an integer k.
Subarray Sum Equals K
Given an array of integers nums and an integer k, return the total number of subarrays whose sum equals to k.
Unique Substrings in Wraparound String
We define the string base to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so base will look like this: Given a string s, return the number of unique...
Maximum Square Area by Removing Fences From a Field
There is a large (m - 1) x (n - 1) rectangular field with corners at (1, 1) and (m, n) containing some horizontal and vertical fences given in arrays hFences and vFences...
Valid Palindrome
A phrase is a palindrome if, after converting all uppercase letters into lowercase letters and removing all non-alphanumeric characters, it reads the same forward and backward.
Maximum Frequency of an Element After Performing Operations I
You are given an integer array nums and two integers k and numOperations.
Rearrange Spaces Between Words
You are given a string text of words that are placed among some number of spaces.
Water Bottles II
You are given two integers numBottles and numExchange.
Minimum Weighted Subgraph With the Required Paths II
You are given an undirected weighted tree with n nodes, numbered from 0 to n - 1.
Maximum Number of Balls in a Box
You are working in a ball factory where you have n balls numbered from lowLimit up to highLimit inclusive (i.e., n == highLimit - lowLimit + 1), and an infinite number of boxes...
Minimum Operations to Convert All Elements to Zero
You are given an array nums of size n, consisting of non-negative integers.
Is Subsequence
Given two strings s and t, return true if s is a subsequence of t, or false otherwise.
Minimum Absolute Difference Between Elements With Constraint
You are given a 0-indexed integer array nums and an integer x.
Stone Game VI
Alice and Bob take turns playing a game, with Alice starting first.
Final Prices With a Special Discount in a Shop
You are given an integer array prices where prices[i] is the price of the ith item in a shop.
Minimum Absolute Sum Difference
You are given two positive integer arrays nums1 and nums2, both of length n.
Find Three Consecutive Integers That Sum to a Given Number
Given an integer num, return three consecutive integers (as a sorted array) that sum to num.
Count Partitions with Even Sum Difference
You are given an integer array nums of length n.
Find Triangular Sum of an Array
You are given a 0-indexed integer array nums, where nums[i] is a digit between 0 and 9 (inclusive).
Count Alternating Subarrays
You are given a binary array nums.
Find The First Player to win K Games in a Row
A competition consists of n players numbered from 0 to n - 1.
Maximize Greatness of an Array
You are given a 0-indexed integer array nums.
Maximum Enemy Forts That Can Be Captured
You are given a 0-indexed integer array forts of length n representing the positions of several forts.
Maximum Unique Subarray Sum After Deletion
You are given an integer array nums.
Longest Mountain in Array
You may recall that an array arr is a mountain array if and only if: Given an integer array arr, return the length of the longest subarray, which is a mountain.
Find the Winning Player in Coin Game
You are given two positive integers x and y, denoting the number of coins with values 75 and 10 respectively.
Prime Subtraction Operation
You are given a 0-indexed integer array nums of length n.
Count the Number of Vowel Strings in Range
You are given a 0-indexed array of string words and two integers left and right.
Sum of Digit Differences of All Pairs
You are given an array nums consisting of positive integers where all integers have the same number of digits.
Number of Distinct Averages
You are given a 0-indexed integer array nums of even length.
Optimal Division
You are given an integer array nums.
Memoize II
Given a function fn, return a memoized version of that function.
Find Minimum Operations to Make All Elements Divisible by Three
You are given an integer array nums.
Asteroid Collision
We are given an array asteroids of integers representing asteroids in a row.
Find Indices With Index and Value Difference II
You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference.
Crawler Log Folder
A file system keeps a log each time some user performs a change folder operation.
Escape The Ghosts
You are playing a simplified PAC-MAN game on an infinite 2-D grid.
Extra Characters in a String
You are given a 0-indexed string s and a dictionary of words dictionary.
Minimize String Length
Given a string s, you have two types of operation: Your task is to minimize the length of s by performing the above operations zero or more times.
Coin Change
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
Maximum Profit of Operating a Centennial Wheel
You are the operator of a Centennial Wheel that has four gondolas, and each gondola has room for up to four people.
Find Minimum Cost to Remove Array Elements
You are given an integer array nums.
Make Array Elements Equal to Zero
You are given an integer array nums.
Subarrays Distinct Element Sum of Squares I
You are given a 0-indexed integer array nums.
Exclusive Time of Functions
On a single-threaded CPU, we execute a program containing n functions.
IPO
Suppose a startup will begin its IPO soon.
Minimum Time to Visit a Cell In a Grid
You are given a m x n matrix grid consisting of non-negative integers where grid[row][col] represents the minimum time required to be able to visit the cell (row, col), which...
Find Kth Largest XOR Coordinate Value
You are given a 2D matrix of size m x n, consisting of non-negative integers.
Minimum Number of Valid Strings to Form Target I
You are given an array of strings words and a string target.
Prime Number of Set Bits in Binary Representation
Given two integers left and right, return the count of numbers in the inclusive range [left, right] having a prime number of set bits in their binary representation.
Spiral Matrix II
Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.
Number of Submatrices That Sum to Target
Given a matrix and a target, return the number of non-empty submatrices that sum to target.
Best Time to Buy and Sell Stock with Cooldown
You are given an array prices where prices[i] is the price of a given stock on the ith day.
Count Binary Substrings
Given a binary string s, return the number of non-empty substrings that have the same number of 0's and 1's, and all the 0's and all the 1's in these substrings are grouped...
Maximum Area Rectangle With Point Constraints II
There are n points on an infinite plane.
Find Common Characters
Given a string array words, return an array of all characters that show up in all strings within the words (including duplicates).
Find the Integer Added to Array I
You are given two arrays of equal length, nums1 and nums2.
Find the XOR of Numbers Which Appear Twice
You are given an array nums, where each number in the array appears either once or twice.
Minimum Number of Changes to Make Binary String Beautiful
You are given a 0-indexed binary string s having an even length.
Construct K Palindrome Strings
Given a string s and an integer k, return true if you can use all the characters in s to construct non-empty k palindrome strings or false otherwise.
Check If It Is a Good Array
Given an array nums of positive integers.
Cycle Length Queries in a Tree
You are given an integer n.
Goal Parser Interpretation
You own a Goal Parser that can interpret a string command.
Decode Ways II
A message containing letters from A-Z can be encoded into numbers using the following mapping: To decode an encoded message, all the digits must be grouped then mapped back into...
Minimum Number of Pushes to Type Word I
You are given a string word containing distinct lowercase English letters.
Largest Rectangle in Histogram
Given an array of integers heights representing the histogram's bar height where the width of each bar is 1, return the area of the largest rectangle in the histogram.
Find Pivot Index
Given an array of integers nums, calculate the pivot index of this array.
Minimum Bit Flips to Convert Number
A bit flip of a number x is choosing a bit in the binary representation of x and flipping it from either 0 to 1 or 1 to 0.
Minimum Time to Make Array Sum At Most x
You are given two 0-indexed integer arrays nums1 and nums2 of equal length.
Count Unique Characters of All Substrings of a Given String
Let's define a function countUniqueChars(s) that returns the number of unique characters in s.
Closest Divisors
Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2.
Richest Customer Wealth
You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the ith customer has in the jth bank.
Find Peak Element
A peak element is an element that is strictly greater than its neighbors.
Number of Music Playlists
Your music player contains n different songs.
Shortest Path in Binary Matrix
Given an n x n binary matrix grid, return the length of the shortest clear path in the matrix.
Minimize the Maximum Edge Weight of Graph
You are given two integers, n and threshold, as well as a directed weighted graph of n nodes numbered from 0 to n - 1.
Apply Operations to Make String Empty
You are given a string s.
Number of Students Doing Homework at a Given Time
Given two integer arrays startTime and endTime and given an integer queryTime.
Minimum Area Rectangle II
You are given an array of points in the X-Y plane points where points[i] = [xi, yi].
Minimum Reverse Operations
You are given an integer n and an integer p representing an array arr of length n where all elements are set to 0's, except position p which is set to 1.
Steps to Make Array Non-decreasing
You are given a 0-indexed integer array nums.
Count the Number of Incremovable Subarrays II
You are given a 0-indexed array of positive integers nums.
Shopping Offers
In an online store, there are n items to sell.
Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits are different.
Minimize XOR
Given two positive integers num1 and num2, find the positive integer x such that: Note that XOR is the bitwise XOR operation.
Sum of Beauty of All Substrings
The beauty of a string is the difference in frequencies between the most frequent and least frequent characters.
Equal Sum Grid Partition II
You are given an m x n matrix grid of positive integers.
Minimum Hours of Training to Win a Competition
You are entering a competition, and are given two positive integers initialEnergy and initialExperience denoting your initial energy and initial experience respectively.
Circular Permutation in Binary Representation
Given 2 integers n and start.
Convert to Base -2
Given an integer n, return a binary string representing its representation in base -2.
Maximum Bags With Full Capacity of Rocks
You have n bags numbered from 0 to n - 1.
Find the K-or of an Array
You are given an integer array nums, and an integer k.
Rabbits in Forest
There is a forest with an unknown number of rabbits.
Distribute Candies Among Children II
You are given two positive integers n and limit.
Maximum Number of Moves in a Grid
You are given a 0-indexed m x n matrix grid consisting of positive integers.
Find Duplicate File in System
Given a list paths of directory info, including the directory path, and all the files with contents in this directory, return all the duplicate files in the file system in terms...
Find the Smallest Divisor Given a Threshold
Given an array of integers nums and an integer threshold, we will choose a positive integer divisor, divide all the array by it, and sum the division's result.
Rectangle Area II
You are given a 2D array of axis-aligned rectangles.
Check If a String Can Break Another String
Given two strings: s1 and s2 with the same size, check if some permutation of string s1 can break some permutation of string s2 or vice-versa.
Prime Pairs With Target Sum
You are given an integer n.
Plates Between Candles
There is a long table with a line of plates and candles arranged on top of it.
Car Fleet II
There are n cars traveling at different speeds in the same direction along a one-lane road.
Create Target Array in the Given Order
Given two arrays of integers nums and index.
DI String Match
A permutation perm of n + 1 integers of all the integers in the range [0, n] can be represented as a string s of length n where: Given a string s, reconstruct the permutation perm...
Longest Continuous Increasing Subsequence
Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e.
Spiral Matrix
Given an m x n matrix, return all elements of the matrix in spiral order.
Sum of Matrix After Queries
You are given an integer n and a 0-indexed 2D array queries where queries[i] = [typei, indexi, vali].
Orderly Queue
You are given a string s and an integer k.
Split a String in Balanced Strings
Balanced strings are those that have an equal quantity of 'L' and 'R' characters.
Reordered Power of 2
You are given an integer n.
Number of Digit One
Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.
Short Encoding of Words
A valid encoding of an array of words is any reference string s and array of indices indices such that: Given an array of words, return the length of the shortest reference string...
Check If a String Contains All Binary Codes of Size K
Given a binary string s and an integer k, return true if every binary code of length k is a substring of s.
Find a Peak Element II
A peak element in a 2D grid is an element that is strictly greater than all of its adjacent neighbors to the left, right, top, and bottom.
Replace the Substring for Balanced String
You are given a string s of length n containing only four kinds of characters: 'Q', 'W', 'E', and 'R'.
Min Cost Climbing Stairs
You are given an integer array cost where cost[i] is the cost of ith step on a staircase.
Count the Number of Houses at a Certain Distance II
You are given three positive integers n, x, and y.
Minimum Add to Make Parentheses Valid
A parentheses string is valid if and only if: You are given a parentheses string s.
Median of Two Sorted Arrays
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
Valid Arrangement of Pairs
You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi].
Determine if String Halves Are Alike
You are given a string s of even length.
Dota2 Senate
In the world of Dota2, there are two parties: the Radiant and the Dire.
Count Number of Trapezoids II
You are given a 2D integer array points where points[i] = [xi, yi] represents the coordinates of the ith point on the Cartesian plane.
Tag Validator
Given a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid.
Find Indices of Stable Mountains
There are n mountains in a row, and each mountain has a height.
Maximum and Minimum Sums of at Most Size K Subarrays
You are given an integer array nums and a positive integer k.
Cherry Pickup II
You are given a rows x cols matrix grid representing a field of cherries where grid[i][j] represents the number of cherries that you can collect from the (i, j) cell.
Last Stone Weight II
You are given an array of integers stones where stones[i] is the weight of the ith stone.
Path Crossing
Given a string path, where path[i] = 'N', 'S', 'E' or 'W', each representing moving one unit north, south, east, or west, respectively.
Kth Smallest Number in Multiplication Table
Nearly everyone has used the Multiplication Table.
Monotone Increasing Digits
An integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.
Find Score of an Array After Marking All Elements
You are given an array nums consisting of positive integers.
Largest 1-Bordered Square
Given a 2D grid of 0s and 1s, return the number of elements in the largest square subgrid that has all 1s on its border, or 0 if such a subgrid doesn't exist in the grid.
Combination Sum III
Find all valid combinations of k numbers that sum up to n such that the following conditions are true: Return a list of all possible valid combinations.
Substring Matching Pattern
You are given a string s and a pattern string p, where p contains exactly one '*' character.
Water Bottles
There are numBottles water bottles that are initially full of water.
Concatenation of Array
Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed).
Substring With Largest Variance
The variance of a string is defined as the largest difference between the number of occurrences of any 2 characters present in the string.
Maximum Trailing Zeros in a Cornered Path
You are given a 2D integer array grid of size m x n, where each cell contains a positive integer.
First Missing Positive
Given an unsorted integer array nums.
Available Captures for Rook
You are given an 8 x 8 matrix representing a chessboard.
Minimum Cost to Convert String I
You are given two 0-indexed strings source and target, both of length n and consisting of lowercase English letters.
Find the Maximum Number of Elements in Subset
You are given an array of positive integers nums.
Binary Watch
A binary watch has 4 LEDs on the top to represent the hours (0-11), and 6 LEDs on the bottom to represent the minutes (0-59).
Find First Palindromic String in the Array
Given an array of strings words, return the first palindromic string in the array.
Find the City With the Smallest Number of Neighbors at a Threshold Distance
There are n cities numbered from 0 to n-1.
132 Pattern
Given an array of n integers nums, a 132 pattern is a subsequence of three integers nums[i], nums[j] and nums[k] such that i < j < k and nums[i] < nums[k] < nums[j].
Valid Perfect Square
Given a positive integer num, return true if num is a perfect square or false otherwise.
Rank Teams by Votes
In a special ranking system, each voter gives a rank from highest to lowest to all teams participating in the competition.
Minimum Stability Factor of Array
You are given an integer array nums and an integer maxC.
Minimum Number of Chairs in a Waiting Room
You are given a string s.
Groups of Special-Equivalent Strings
You are given an array of strings of the same length words.
Taking Maximum Energy From the Mystic Dungeon
In a mystic dungeon, n magicians are standing in a line.
Slowest Key
A newly designed keypad was tested, where a tester pressed a sequence of n keys, one at a time.
Merge Sorted Array
You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively.
Minimize Malware Spread II
You are given a network of n nodes represented as an n x n adjacency matrix graph, where the ith node is directly connected to the jth node if graph[i][j] == 1.
Find Good Days to Rob the Bank
You and a gang of thieves are planning on robbing a bank.
Maximum Number of Jumps to Reach the Last Index
You are given a 0-indexed array nums of n integers and an integer target.
Maximum Weighted K-Edge Path
You are given an integer n and a Directed Acyclic Graph (DAG) with n nodes labeled from 0 to n - 1.
Maximum Difference Between Increasing Elements
Given a 0-indexed integer array nums of size n, find the maximum difference between nums[i] and nums[j] (i.e., nums[j] - nums[i]), such that 0 <= i < j < n and nums[i] < nums[j].
Closest Prime Numbers in Range
Given two positive integers left and right, find the two integers num1 and num2 such that: Return the positive integer array ans = [num1, num2].
Find if Digit Game Can Be Won
You are given an array of positive integers nums.
Maximum Difference Between Even and Odd Frequency II
You are given a string s and an integer k.
Circle and Rectangle Overlapping
You are given a circle represented as (radius, xCenter, yCenter) and an axis-aligned rectangle represented as (x1, y1, x2, y2), where (x1, y1) are the coordinates of the...
Find Subarray With Bitwise OR Closest to K
You are given an array nums and an integer k.
Count The Repetitions
We define str = [s, n] as the string str which consists of the string s concatenated n times.
Smallest Value of the Rearranged Number
You are given an integer num.
Remove Colored Pieces if Both Neighbors are the Same Color
There are n pieces arranged in a line, and each piece is colored either by 'A' or by 'B'.
Palindrome Linked List
Check whether the values in a singly-linked list read the same forwards and backwards.
Merge K Sorted Linked Lists
Merge k independently sorted linked lists into a single sorted linked list.
Add Two Numbers as Linked Lists
Add two non-negative integers stored as reverse-order digit linked lists and return the sum in the same format.
How Strings Work — API Cheat Sheet
No exercise here — just the string methods you actually reach for in an interview, side by side across Java, C#, Python, and JavaScript/TypeScript.
How Recursion Works — Mental Model Cheat Sheet
No exercise here — the base-case/recursive-case shape every recursive function shares, plus the call-stack mechanics and syntax across all five languages.
Insert into a Binary Search Tree
Insert a new value into a binary search tree while preserving its ordering property.
How Hash Maps Work — API Cheat Sheet
No exercise here — the put/get/containsKey-style methods across Java, C#, Python, and JavaScript/TypeScript, the single most-used tool in interview problems.
How Linked Lists Work — API Cheat Sheet
No exercise here — what a linked list actually is, which languages have a built-in one, and the handful of node operations interview problems reuse over and over.
How Arrays Work — API Cheat Sheet
No exercise here — just how to declare, index, iterate, and manipulate raw arrays (and 2D grids) across Java, C#, Python, and JavaScript/TypeScript.
Invert Binary Tree
Flip a binary tree into its mirror image by swapping every node's left and right children.
Remove Duplicates From a Sorted Linked List
Collapse consecutive duplicate values in a sorted singly-linked list so each value appears once.
Validate a Binary Search Tree
Determine whether a binary tree satisfies the binary search tree property at every node, not just between direct parent-child pairs.
How Sorted Sets Work — API Cheat Sheet
No exercise here — TreeSet/SortedSet and their nearest equivalents, for when you need unique values kept in sorted order with fast lookups.
Partition a List Around a Value
Stably rearrange a linked list so every node less than a pivot value comes before every node greater than or equal to it.
Maximum Subarray
Find the contiguous subarray with the largest sum.
Binary Tree Basics
An introduction to the Node and BinTree building blocks used throughout the Binary Trees series, plus a sample tree these exercises build on.
Reorder a Linked List
Rearrange a singly-linked list by alternating nodes from the front and the back until they meet in the middle.
Longest Happy String
A string s is called happy if it satisfies the following conditions: Given three integers a, b, and c, return the longest possible happy string.
Find Players With Zero or One Losses
You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match.
Beautiful Towers II
You are given a 0-indexed array maxHeights of n integers.
Maximum Width Ramp
A ramp in an integer array nums is a pair (i, j) for which i < j and nums[i] <= nums[j].
Largest Submatrix With Rearrangements
You are given a binary matrix matrix of size m x n, and you are allowed to rearrange the columns of the matrix in any order.
Smallest Sufficient Team
In a project, you have a list of required skills req_skills, and a list of people.
Minimize Manhattan Distances
You are given an array points representing integer coordinates of some points on a 2D plane, where points[i] = [xi, yi].
Bus Routes
You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever.
Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts
You are given a rectangular cake of size h x w and two arrays of integers horizontalCuts and verticalCuts where: Return the maximum area of a piece of cake after you cut at each...
Final Value of Variable After Performing Operations
There is a programming language with only four operations and one variable X: Initially, the value of X is 0.
Minimize Length of Array Using Operations
You are given a 0-indexed integer array nums containing positive integers.
Minimum Amount of Time to Fill Cups
You have a water dispenser that can dispense cold, warm, and hot water.
Minimum Swaps to Sort by Digit Sum
You are given an array nums of distinct positive integers.
Check If Digits Are Equal in String After Operations II
You are given a string s consisting of digits.
Maximum XOR After Operations
You are given a 0-indexed integer array nums.
Find Array Given Subset Sums
You are given an integer n representing the length of an unknown array that you are trying to recover.
Minimum Operations to Collect Elements
You are given an array nums of positive integers and an integer k.
Reshape the Matrix
In MATLAB, there is a handy function called reshape which can reshape an m x n matrix into a new one with a different size r x c keeping its original data.
Snakes and Ladders
You are given an n x n integer matrix board where the cells are labeled from 1 to n2 in a Boustrophedon style starting from the bottom left of the board (i.e.
Total Characters in String After Transformations I
You are given a string s and an integer t, representing the number of transformations to perform.
Longest Common Subsequence
Given two strings text1 and text2, return the length of their longest common subsequence.
Max Consecutive Ones III
Given a binary array nums and an integer k, return the maximum number of consecutive 1's in the array if you can flip at most k 0's.
Tree of Coprimes
There is a tree (i.e., a connected, undirected graph that has no cycles) consisting of n nodes numbered from 0 to n - 1 and exactly n - 1 edges.
Maximum Rows Covered by Columns
You are given an m x n binary matrix matrix and an integer numSelect.
Decode Ways
You have intercepted a secret message encoded as a string of numbers.
Decompress Run-Length Encoded List
We are given a list nums of integers representing a list compressed with run-length encoding.
Sum of Beauty in the Array
You are given a 0-indexed integer array nums.
Fraction to Recurring Decimal
Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.
Previous Permutation With One Swap
Given an array of positive integers arr (not necessarily distinct), return the lexicographically largest permutation that is smaller than arr, that can be made with exactly one...
Distribute Repeating Integers
You are given an array of n integers, nums, where there are at most 50 unique values in the array.
Count the Number of Inversions
You are given an integer n and a 2D array requirements, where requirements[i] = [endi, cnti] represents the end index and the inversion count of each requirement.
Difference Between Maximum and Minimum Price Sum
There exists an undirected and initially unrooted tree with n nodes indexed from 0 to n - 1.
Count Ways To Build Good Strings
Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at each step perform either of the following: This can be...
Hexadecimal and Hexatrigesimal Conversion
You are given an integer n.
Maximum Fruits Harvested After at Most K Steps
Fruits are available at some positions on an infinite x-axis.
Count Almost Equal Pairs II
Attention: In this version, the number of operations that can be performed, has been increased to twice.
Points That Intersect With Cars
You are given a 0-indexed 2D integer array nums representing the coordinates of the cars parking on a number line.
Cracking the Safe
There is a safe protected by a password.
Bricks Falling When Hit
You are given an m x n binary grid, where each 1 represents a brick and 0 represents an empty space.
Latest Time by Replacing Hidden Digits
You are given a string time in the form of hh:mm, where some of the digits in the string are hidden (represented by ?).
Maximum Number of Occurrences of a Substring
Given a string s, return the maximum number of occurrences of any substring under the following rules:
String Without AAA or BBB
Given two integers a and b, return any string s such that:
Tallest Billboard
You are installing a billboard and want it to have the largest height.
Maximum Value of an Ordered Triplet I
You are given a 0-indexed integer array nums.
Count Numbers with Non-Decreasing Digits
You are given two integers, l and r, represented as strings, and an integer b.
Number of Substrings Containing All Three Characters
Given a string s consisting only of characters a, b and c.
Smallest Subsequence of Distinct Characters
Given a string s, return the lexicographically smallest subsequence of s that contains all the distinct characters of s exactly once.
Shortest Path in a Grid with Obstacles Elimination
You are given an m x n integer matrix grid where each cell is either 0 (empty) or 1 (obstacle).
Keys and Rooms
There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0.
Apple Redistribution into Boxes
You are given an array apple of size n and an array capacity of size m.
Number of Different Integers in a String
You are given a string word that consists of digits and lowercase English letters.
Path with Maximum Gold
In a gold mine grid of size m x n, each cell in this mine has an integer representing the amount of gold in that cell, 0 if it is empty.
Best Time to Buy and Sell Stock V
You are given an integer array prices where prices[i] is the price of a stock in dollars on the ith day, and an integer k.
Split Array With Same Average
You are given an integer array nums.
Couples Holding Hands
There are n couples sitting in 2n seats arranged in a row and want to hold hands.
Minimum Time to Complete Trips
You are given an array time where time[i] denotes the time taken by the ith bus to complete one trip.
Sum of Distances in Tree
There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.
Count the Number of Fair Pairs
Given a 0-indexed integer array nums of size n and two integers lower and upper, return the number of fair pairs.
Maximum Energy Boost From Two Drinks
You are given two integer arrays energyDrinkA and energyDrinkB of the same length n by a futuristic sports scientist.
Minimum Distance to the Target Element
Given an integer array nums (0-indexed) and two integers target and start, find an index i such that nums[i] == target and abs(i - start) is minimized.
Maximum Number of Groups Entering a Competition
You are given a positive integer array grades which represents the grades of students in a university.
Lexicographically Smallest String After Substring Operation
Given a string s consisting of lowercase English letters.
Merge Triplets to Form Target Triplet
A triplet is an array of three integers.
Find XOR Sum of All Pairs Bitwise AND
The XOR sum of a list is the bitwise XOR of all its elements.
Number of Valid Clock Times
You are given a string of length 5 called time, representing the current time on a digital clock in the format "hh:mm".
Divide Intervals Into Minimum Number of Groups
You are given a 2D integer array intervals where intervals[i] = [lefti, righti] represents the inclusive interval [lefti, righti].
Longest Increasing Subsequence II
You are given an integer array nums and an integer k.
Form Largest Integer With Digits That Add up to Target
Given an array of integers cost and an integer target, return the maximum integer you can paint under the following rules: Since the answer may be very large, return it as a string.
X of a Kind in a Deck of Cards
You are given an integer array deck where deck[i] represents the number written on the ith card.
Maximize Sum of Weights after Edge Removals
There exists an undirected tree with n nodes numbered 0 to n - 1.
Make K-Subarray Sums Equal
You are given a 0-indexed integer array arr and an integer k.
Splitting a String Into Descending Consecutive Values
You are given a string s that consists of only digits.
Coin Change II
You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.
Maximum Non Negative Product in a Matrix
You are given a m x n matrix grid.
Maximum Balanced Subsequence Sum
You are given a 0-indexed integer array nums.
Remove Duplicate Letters
Given a string s, remove duplicate letters so that every letter appears once and only once.
Count Different Palindromic Subsequences
Given a string s, return the number of different non-empty palindromic subsequences in s.
Preimage Size of Factorial Zeroes Function
Let f(x) be the number of zeroes at the end of x!.
Non-negative Integers without Consecutive Ones
Given a positive integer n, return the number of the integers in the range [0, n] whose binary representations do not contain consecutive ones.
Most Profit Assigning Work
You have n jobs and m workers.
Find the Number of Good Pairs I
You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively.
Search Insert Position
Given a sorted array of distinct integers and a target value, return the index if the target is found.
Find the Maximum Sum of Node Values
There exists an undirected tree with n nodes numbered 0 to n - 1.
Russian Doll Envelopes
You are given a 2D array of integers envelopes where envelopes[i] = [wi, hi] represents the width and the height of an envelope.
Check Distances Between Same Letters
You are given a 0-indexed string s consisting of only lowercase English letters, where each letter in s appears exactly twice.
Sender With Largest Word Count
You have a chat log of n messages.
Reformat Phone Number
You are given a phone number as a string number.
Minimum Array Changes to Make Differences Equal
You are given an integer array nums of size n where n is even, and an integer k.
Minimum Size Subarray in Infinite Array
You are given a 0-indexed array nums and an integer target.
Largest 3-Same-Digit Number in String
You are given a string num representing a large integer.
Find Minimum in Rotated Sorted Array
Suppose an array of length n sorted in ascending order is rotated between 1 and n times.
Minimum Cost to Make All Characters Equal
You are given a 0-indexed binary string s of length n on which you can apply two types of operations: Return the minimum cost to make all characters of the string equal.
Number of Restricted Paths From First to Last Node
There is an undirected weighted connected graph.
Delete and Earn
You are given an integer array nums.
Minimum Moves to Reach Target in Grid
You are given four integers sx, sy, tx, and ty, representing two points (sx, sy) and (tx, ty) on an infinitely large 2D grid.
Target Sum
You are given an integer array nums and an integer target.
Zero Array Transformation II
You are given an integer array nums of length n and a 2D array queries where queries[i] = [li, ri, vali].
Tiling a Rectangle with the Fewest Squares
Given a rectangle of size n x m, return the minimum number of integer-sided squares that tile the rectangle.
Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.
Count the Number of Powerful Integers
You are given three integers start, finish, and limit.
Sequential Digits
An integer has sequential digits if and only if each digit in the number is one more than the previous digit.
Hand of Straights
Alice has some number of cards and she wants to rearrange the cards into groups so that each group is of size groupSize, and consists of groupSize consecutive cards.
Sum of Unique Elements
You are given an integer array nums.
Remove All Adjacent Duplicates in String II
You are given a string s and an integer k, a k duplicate removal consists of choosing k adjacent and equal letters from s and removing them, causing the left and the right side of...
Count the Hidden Sequences
You are given a 0-indexed array of n integers differences, which describes the differences between each pair of consecutive integers of a hidden sequence of length (n + 1).
Minimum Moves to Make Array Complementary
You are given an integer array nums of even length n and an integer limit.
Number of Dice Rolls With Target Sum
You have n dice, and each dice has k faces numbered from 1 to k.
Relocate Marbles
You are given a 0-indexed integer array nums representing the initial positions of some marbles.
Intervals Between Identical Elements
You are given a 0-indexed array of n integers arr.
Count Pairs of Connectable Servers in a Weighted Tree Network
You are given an unrooted weighted tree with n vertices representing servers numbered from 0 to n - 1, an array edges where edges[i] = [ai, bi, weighti] represents a bidirectional...
Ugly Number II
An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.
Count Days Spent Together
Alice and Bob are traveling to Rome for separate business meetings.
Manhattan Distances of All Arrangements of Pieces
You are given three integers m, n, and k.
Closest Subsequence Sum
You are given an integer array nums and an integer goal.
Rearrange Characters to Make Target String
You are given two 0-indexed strings s and target.
Count Good Triplets
Given an array of integers arr, and three integers a, b and c.
Check if There Is a Valid Parentheses String Path
A parentheses string is a non-empty string consisting only of '(' and ')'.
How Many Numbers Are Smaller Than the Current Number
Given the array nums, for each nums[i] find out how many numbers in the array are smaller than it.
Valid Mountain Array
Given an array of integers arr, return true if and only if it is a valid mountain array.
Number of Ways to Split a String
Given a binary string s, you can split s into 3 non-empty strings s1, s2, and s3 where s1 + s2 + s3 = s.
Maximum Profit from Valid Topological Order in DAG
You are given a Directed Acyclic Graph (DAG) with n nodes labeled from 0 to n - 1, represented by a 2D array edges, where edges[i] = [ui, vi] indicates a directed edge from node...
Repeated String Match
Given two strings a and b, return the minimum number of times you should repeat string a so that string b is a substring of it.
Rotting Oranges
You are given an m x n grid where each cell can have one of three values: Every minute, any fresh orange that is 4-directionally adjacent to a rotten orange becomes rotten.
Categorize Box According to Criteria
Given four integers length, width, height, and mass, representing the dimensions and mass of a box, respectively, return a string representing the category of the box.
Find the Sum of the Power of All Subsequences
You are given an integer array nums of length n and a positive integer k.
Matrix Block Sum
Given a m x n matrix mat and an integer k, return a matrix answer where each answer[i][j] is the sum of all elements mat[r][c] for:
String Matching in an Array
Given an array of string words, return all strings in words that are a substring of another word.
Domino and Tromino Tiling
You have two types of tiles: a 2 x 1 domino shape and a tromino shape.
Find the String with LCP
We define the lcp matrix of any 0-indexed string word of n lowercase English letters as an n x n grid such that: Given an n x n matrix lcp, return the alphabetically smallest...
Check if Strings Can be Made Equal With Operations II
You are given two strings s1 and s2, both of length n, consisting of lowercase English letters.
Count of Interesting Subarrays
You are given a 0-indexed integer array nums, an integer modulo, and an integer k.
Find the Power of K-Size Subarrays II
You are given an array of integers nums of length n and a positive integer k.
Ugly Number
An ugly number is a positive integer which does not have a prime factor other than 2, 3, and 5.
Find Longest Awesome Substring
You are given a string s.
Valid Triangle Number
Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.
Subarray Product Less Than K
Given an array of integers nums and an integer k, return the number of contiguous subarrays where the product of all the elements in the subarray is strictly less than k.
Longest Increasing Path in a Matrix
Given an m x n integers matrix, return the length of the longest increasing path in matrix.
Minimum Fuel Cost to Report to the Capital
There is a tree (i.e., a connected, undirected graph with no cycles) structure country network consisting of n cities numbered from 0 to n - 1 and exactly n - 1 roads.
Maximum Sum With Exactly K Elements
You are given a 0-indexed integer array nums and an integer k.
Cells in a Range on an Excel Sheet
A cell (r, c) of an excel sheet is represented as a string "<col><row>" where: You are given a string s in the format "<col1><row1>:<col2><row2>", where <col1> represents the...
Make Two Arrays Equal by Reversing Subarrays
You are given two integer arrays of equal length target and arr.
Maximum Product of the Length of Two Palindromic Subsequences
Given a string s, find two disjoint palindromic subsequences of s such that the product of their lengths is maximized.
Sort Even and Odd Indices Independently
You are given a 0-indexed integer array nums.
Set Matrix Zeroes
Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0's.
Count the Number of Infection Sequences
You are given an integer n and an array sick sorted in increasing order, representing positions of infected people in a line of n people.
Compare Strings by Frequency of the Smallest Character
Let the function f(s) be the frequency of the lexicographically smallest character in a non-empty string s.
Minimum Operations to Form Subsequence With Target Sum
You are given a 0-indexed array nums consisting of non-negative powers of 2, and an integer target.
Minimum Insertion Steps to Make a String Palindrome
Given a string s.
Multiply Strings
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
Closest Equal Element Queries
You are given a circular array nums and an array queries.
Solve the Equation
Solve a given equation and return the value of 'x' in the form of a string "x=#value".
Make Array Empty
You are given an integer array nums containing distinct numbers, and you can perform the following operations until the array is empty: Return an integer denoting the number of...
Minimum Deletions to Make Array Divisible
You are given two positive integer arrays nums and numsDivide.
Count Collisions of Monkeys on a Polygon
There is a regular convex polygon with n vertices.
Construct the Longest New String
You are given three integers x, y, and z.
Sort the Students by Their Kth Score
There is a class with m students and n exams.
Maximum Number of Distinct Elements After Operations
You are given an integer array nums and an integer k.
Number of Pairs of Interchangeable Rectangles
You are given n rectangles represented by a 0-indexed 2D integer array rectangles, where rectangles[i] = [widthi, heighti] denotes the width and height of the ith rectangle.
Check if All the Integers in a Range Are Covered
You are given a 2D integer array ranges and two integers left and right.
Number of Beautiful Pairs
You are given a 0-indexed integer array nums.
Form Array by Concatenating Subarrays of Another Array
You are given a 2D integer array groups of length n.
Most Common Word
Given a string paragraph and a string array of the banned words banned, return the most frequent word that is not banned.
Number of Subarrays With AND Value of K
Given an array of integers nums and an integer k, return the number of subarrays of nums where the bitwise AND of the elements of the subarray equals k.
Second Largest Digit in a String
Given an alphanumeric string s, return the second largest numerical digit that appears in s, or -1 if it does not exist.
Count Items Matching a Rule
You are given an array items, where each items[i] = [typei, colori, namei] describes the type, color, and name of the ith item.
Max Consecutive Ones
Given a binary array nums, return the maximum number of consecutive 1's in the array.
Maximum Height of a Triangle
You are given two integers red and blue representing the count of red and blue colored balls.
Sleep
Given a positive integer millis, write an asynchronous function that sleeps for millis milliseconds.
Minimum Difference Between Largest and Smallest Value in Three Moves
You are given an integer array nums.
Find the Safest Path in a Grid
You are given a 0-indexed 2D matrix grid of size n x n, where (r, c) represents: You are initially positioned at cell (0, 0).
Calculate Delayed Arrival Time
You are given a positive integer arrivalTime denoting the arrival time of a train in hours, and another positive integer delayedTime denoting the amount of delay in hours.
Check if it is Possible to Split Array
You are given an array nums of length n and an integer m.
Smallest Range Covering Elements from K Lists
You have k lists of sorted integers in non-decreasing order.
Minimum XOR Sum of Two Arrays
You are given two integer arrays nums1 and nums2 of length n.
Number of Boomerangs
You are given n points in the plane that are all distinct, where points[i] = [xi, yi].
Maximum Score of a Good Subarray
You are given an array of integers nums (0-indexed) and an integer k.
Count Number of Rectangles Containing Each Point
You are given a 2D integer array rectangles where rectangles[i] = [li, hi] indicates that ith rectangle has a length of li and a height of hi.
Word Ladder II
A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ...
Transformed Array
You are given an integer array nums that represents a circular array.
Greatest Common Divisor of Strings
For two strings s and t, we say "t divides s" if and only if s = t + t + t + ...
Positions of Large Groups
In a string s of lowercase letters, these letters form consecutive groups of the same character.
Disconnect Path in a Binary Matrix by at Most One Flip
You are given a 0-indexed m x n binary matrix grid.
Largest Palindrome Product
Given an integer n, return the largest palindromic integer that can be represented as the product of two n-digits integers.
Number Of Rectangles That Can Form The Largest Square
You are given an array rectangles where rectangles[i] = [li, wi] represents the ith rectangle of length li and width wi.
Longest Common Prefix Between Adjacent Strings After Removals
You are given an array of strings words.
Chunk Array
Given an array arr and a chunk size size, return a chunked array.
Smallest Index With Digit Sum Equal to Index
You are given an integer array nums.
License Key Formatting
You are given a license key represented as a string s that consists of only alphanumeric characters and dashes.
Smallest Subarrays With Maximum Bitwise OR
You are given a 0-indexed array nums of length n, consisting of non-negative integers.
3Sum
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.
Widest Vertical Area Between Two Points Containing No Points
Given n points on a 2D plane where points[i] = [xi, yi], Return the widest vertical area between two points such that no points are inside the area.
Find the Number of Ways to Place People II
You are given a 2D array points of size n x 2 representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].
Adding Spaces to a String
You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added.
Earliest Finish Time for Land and Water Rides II
You are given two categories of theme park attractions: land rides and water rides.
Count Subtrees With Max Distance Between Cities
There are n cities numbered from 1 to n.
Button with Longest Push Time
You are given a 2D array events which represents a sequence of events where a child pushes a series of buttons on a keyboard.
Longest Even Odd Subarray With Threshold
You are given a 0-indexed integer array nums and an integer threshold.
Maximize Amount After Two Days of Conversions
You are given a string initialCurrency, and you start with 1.0 of initialCurrency.
Unique Morse Code Words
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: For convenience, the full table for the 26 letters of...
Last Visited Integers
Given an integer array nums where nums[i] is either a positive integer or -1.
Remove Palindromic Subsequences
You are given a string s consisting only of letters 'a' and 'b'.
Partition Array for Maximum Sum
Given an integer array arr, partition the array into (contiguous) subarrays of length at most k.
Maximum Difference by Remapping a Digit
You are given an integer num.
Minimum Amount of Damage Dealt to Bob
You are given an integer power and two integer arrays damage and health, both having length n.
Minimum Subsequence in Non-Increasing Order
Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non included elements in such subsequence.
Stone Game IX
Alice and Bob continue their games with stones.
Decremental String Concatenation
You are given a 0-indexed array words containing n strings.
Maximum Sum of Distinct Subarrays With Length K
You are given an integer array nums and an integer k.
Smallest Divisible Digit Product I
You are given two integers n and t.
Furthest Building You Can Reach
You are given an integer array heights representing the heights of buildings, some bricks, and some ladders.
Rearrange Words in a Sentence
Given a sentence text (A sentence is a string of space-separated words) in the following format: Your task is to rearrange the words in text such that all words are rearranged in...
Add to Array-Form of Integer
The array-form of an integer num is an array representing its digits in left to right order.
Last Stone Weight
You are given an array of integers stones where stones[i] is the weight of the ith stone.
Minimum Time to Break Locks I
Bob is stuck in a dungeon and must break n locks, each requiring some amount of energy to break.
Maximum Alternating Subsequence Sum
The alternating sum of a 0-indexed array is defined as the sum of the elements at even indices minus the sum of the elements at odd indices.
Excel Sheet Column Title
Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet.
Sum of Variable Length Subarrays
You are given an integer array nums of size n.
Find the K-th Character in String Game II
Alice and Bob are playing a game.
Difference Between Ones and Zeros in Row and Column
You are given a 0-indexed m x n binary matrix grid.
Count of Smaller Numbers After Self
Given an integer array nums, return an integer array counts where counts[i] is the number of smaller elements to the right of nums[i].
Permutation Difference between Two Strings
You are given two strings s and t such that every character occurs at most once in s and t is a permutation of s.
Minimum Number of Food Buckets to Feed the Hamsters
You are given a 0-indexed string hamsters where hamsters[i] is either: You will add some number of food buckets at the empty indices in order to feed the hamsters.
Shift Distance Between Two Strings
You are given two strings s and t of the same length, and two integer arrays nextCost and previousCost.
Climbing Stairs
You are climbing a staircase.
Maximum Subarray With Equal Products
You are given an array of positive integers nums.
Zero Array Transformation III
You are given an integer array nums of length n and a 2D array queries where queries[i] = [li, ri].
Digit Operations to Make Two Integers Equal
You are given two integers n and m that consist of the same number of digits.
Graph Connectivity With Threshold
We have n cities labeled from 1 to n.
Lemonade Change
At a lemonade stand, each lemonade costs $5.
Total Characters in String After Transformations II
You are given a string s consisting of lowercase English letters, an integer t representing the number of transformations to perform, and an array nums of size 26.
Earliest Second to Mark Indices I
You are given two 1-indexed integer arrays, nums and, changeIndices, having lengths n and m, respectively.
Friends Of Appropriate Ages
There are n persons on a social media website.
Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values
You are given two integer arrays x and y, each of length n.
Number of Black Blocks
You are given two integers m and n representing the dimensions of a 0-indexed m x n grid.
Tuple with Same Product
Given an array nums of distinct positive integers, return the number of tuples (a, b, c, d) such that a * b = c * d where a, b, c, and d are elements of nums, and a != b != c != d.
Resulting String After Adjacent Removals
You are given a string s consisting of lowercase English letters.
Shortest Cycle in a Graph
There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1.
Split Strings by Separator
Given an array of strings words and a character separator, split each string in words by separator.
K Highest Ranked Items Within a Price Range
You are given a 0-indexed 2D integer array grid of size m x n that represents a map of the items in a shop.
Permutations
Given an array nums of distinct integers, return all the possible permutations.
Permutation Sequence
The set [1, 2, 3, ..., n] contains a total of n!
Rearrange K Substrings to Form Target String
You are given two strings s and t, both of which are anagrams of each other, and an integer k.
First Completely Painted Row or Column
You are given a 0-indexed integer array arr, and an m x n integer matrix mat.
Basic Calculator IV
Given an expression such as expression = "e + 8 - a + 5" and an evaluation map such as {"e": 1} (given in terms of evalvars = ["e"] and evalints = [1]), return a list of tokens...
Can Place Flowers
You have a long flowerbed in which some of the plots are planted, and some are not.
Minimize Maximum Pair Sum in Array
The pair sum of a pair (a,b) is equal to a + b.
Course Schedule
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.
Number of Ways to Separate Numbers
You wrote down many positive integers in a string called num.
Minimum Adjacent Swaps to Alternate Parity
You are given an array nums of distinct integers.
2 Keys Keyboard
There is only one character 'A' on the screen of a notepad.
Largest Palindromic Number
You are given a string num consisting of digits only.
Largest Color Value in a Directed Graph
There is a directed graph of n colored nodes and m edges.
Palindrome Partitioning III
You are given a string s containing lowercase letters and an integer k.
Number of Strings Which Can Be Rearranged to Contain Substring
You are given an integer n.
Validate IP Address
Given a string queryIP, return "IPv4" if IP is a valid IPv4 address, "IPv6" if IP is a valid IPv6 address or "Neither" if IP is not a correct IP of any type.
Cherry Pickup
You are given an n x n grid representing a field of cherries, each cell is one of three possible integers.
Smallest Good Base
Given an integer n represented as a string, return the smallest good base of n.
Count Number of Ways to Place Houses
There is a street with n * 2 plots, where there are n plots on each side of the street.
Find Sum of Array Product of Magical Sequences
You are given two integers, m and k, and an integer array nums.
Find the Distinct Difference Array
You are given a 0-indexed array nums of length n.
Sort Characters By Frequency
Given a string s, sort it in decreasing order based on the frequency of the characters.
Sorted GCD Pair Queries
You are given an integer array nums of length n and an integer array queries.
Minimum Cost to Merge Stones
There are n piles of stones arranged in a row.
Minimum Time to Collect All Apples in a Tree
Given an undirected tree consisting of n vertices numbered from 0 to n-1, which has some apples in their vertices.
Increment Submatrices by One
You are given a positive integer n, indicating that we initially have an n x n 0-indexed integer matrix mat filled with zeroes.
Minimum Degree of a Connected Trio in a Graph
You are given an undirected graph.
Kth Smallest Element in a Sorted Matrix
Given an n x n matrix where each of the rows and columns is sorted in ascending order, return the kth smallest element in the matrix.
Sort Array By Parity
Given an integer array nums, move all the even integers at the beginning of the array followed by all the odd integers.
Complex Number Multiplication
A complex number can be represented as a string on the form "real+imaginaryi" where: Given two complex numbers num1 and num2 as strings, return a string of the complex number that...
Largest Number At Least Twice of Others
You are given an integer array nums where the largest integer is unique.
Maximum Points After Enemy Battles
You are given an integer array enemyEnergies denoting the energy values of various enemies.
Valid Tic-Tac-Toe State
Given a Tic-Tac-Toe board as a string array board, return true if and only if it is possible to reach this board position during the course of a valid tic-tac-toe game.
Make Array Non-decreasing
You are given an integer array nums.
Longest Word in Dictionary through Deleting
Given a string s and a string array dictionary, return the longest string in the dictionary that can be formed by deleting some of the given string characters.
Counting Words With a Given Prefix
You are given an array of strings words and a string pref.
Unique Paths III
You are given an m x n integer array grid where grid[i][j] could be: Return the number of 4-directional walks from the starting square to the ending square, that walk over every...
Report Spam Message
You are given an array of strings message and an array of strings bannedWords.
Redistribute Characters to Make All Strings Equal
You are given an array of strings words (0-indexed).
Pow(x, n)
Implement pow(x, n), which calculates x raised to the power n (i.e., xn).
Edit Distance
Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2.
Percentage of Letter in String
Given a string s and a character letter, return the percentage of characters in s that equal letter rounded down to the nearest whole percent.
Remove Sub-Folders from the Filesystem
Given a list of folders folder, return the folders after removing all sub-folders in those folders.
N-th Tribonacci Number
The Tribonacci sequence Tn is defined as follows: T0 = 0, T1 = 1, T2 = 1, and Tn+3 = Tn + Tn+1 + Tn+2 for n >= 0.
Largest Number After Digit Swaps by Parity
You are given a positive integer num.
Minimum Number of Taps to Open to Water a Garden
There is a one-dimensional garden on the x-axis.
Check If String Is Transformable With Substring Sort Operations
Given two strings s and t, transform string s into string t using the following operation any number of times: Return true if it is possible to transform s into t.
Open the Lock
You have a lock in front of you with 4 circular wheels.
Count K-Subsequences of a String With Maximum Beauty
You are given a string s and an integer k.
Trapping Rain Water II
Given an m x n integer matrix heightMap representing the height of each unit cell in a 2D elevation map, return the volume of water it can trap after raining.
Set Intersection Size At Least Two
You are given a 2D integer array intervals where intervals[i] = [starti, endi] represents all the integers from starti to endi inclusively.
Check If It Is a Straight Line
You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point.
Letter Combinations of a Phone Number
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.
Count of Substrings Containing Every Vowel and K Consonants II
You are given a string word and a non-negative integer k.
Minimum Number of Operations to Reinitialize a Permutation
You are given an even integer n.
Most Frequent IDs
The problem involves tracking the frequency of IDs in a collection that changes over time.
Powerful Integers
Given three integers x, y, and bound, return a list of all the powerful integers that have a value less than or equal to bound.
Shortest Subarray With OR at Least K I
You are given an array nums of non-negative integers and an integer k.
Longest Valid Parentheses
Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.
Count Almost Equal Pairs I
You are given an array nums consisting of positive integers.
Partition String Into Substrings With Values at Most K
You are given a string s consisting of digits from 1 to 9 and an integer k.
Count the Digits That Divide a Number
Given an integer num, return the number of digits in num that divide num.
Number of Paths with Max Score
You are given a square board of characters.
Lexicographically Smallest String After Adjacent Removals
You are given a string s consisting of lowercase English letters.
Minimum Number Game
You are given a 0-indexed integer array nums of even length and there is also an empty array arr.
Count the Number of Good Subarrays
Given an integer array nums and an integer k, return the number of good subarrays of nums.
Increasing Triplet Subsequence
Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k and nums[i] < nums[j] < nums[k].
Number of Ways to Reorder Array to Get Same BST
Given an array nums that represents a permutation of integers from 1 to n.
Walking Robot Simulation
A robot on an infinite XY-plane starts at point (0, 0) facing north.
Shortest Common Supersequence
Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences.
Find Subsequence of Length K With the Largest Sum
You are given an integer array nums and an integer k.
Minimum Number of Operations to Convert Time
You are given two strings current and correct representing two 24-hour times.
Minimum Number of Coins for Fruits
You are given an 0-indexed integer array prices where prices[i] denotes the number of coins needed to purchase the (i + 1)th fruit.
Count the Number of Square-Free Subsets
You are given a positive integer 0-indexed array nums.
Selling Pieces of Wood
You are given two integers m and n that represent the height and width of a rectangular piece of wood.
Combination Sum
Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target.
Smallest Number With All Set Bits
You are given a positive number n.
Valid Permutations for DI Sequence
You are given a string s of length n where s[i] is either: A permutation perm of n + 1 integers of all the integers in the range [0, n] is called a valid permutation if for all...
Find K Pairs with Smallest Sums
You are given two integer arrays nums1 and nums2 sorted in non-decreasing order and an integer k.
Checking Existence of Edge Length Limited Paths
An undirected graph of n nodes is defined by edgeList, where edgeList[i] = [ui, vi, disi] denotes an edge between nodes ui and vi with distance disi.
Find the Maximum Length of Valid Subsequence II
A subsequence sub of nums with length x is called valid if it satisfies:
Split Array by Prime Indices
You are given an integer array nums.
Check If N and Its Double Exist
Given an array arr of integers, check if there exist two indices i and j such that :
Bag of Tokens
You start with an initial power of power, an initial score of 0, and a bag of tokens given as an integer array tokens, where each tokens[i] denotes the value of tokeni.
Lexicographically Smallest Beautiful String
A string is beautiful if: You are given a beautiful string s of length n and a positive integer k.
Number of Subarrays with Bounded Maximum
Given an integer array nums and two integers left and right, return the number of contiguous non-empty subarrays such that the value of the maximum array element in that subarray...
Maximum Number of Operations With the Same Score II
Given an array of integers called nums, you can perform any of the following operation while nums contains at least 2 elements: The score of the operation is the sum of the...
Maximum Median Sum of Subsequences of Size 3
You are given an integer array nums with a length divisible by 3.
Faulty Keyboard
Your laptop keyboard is faulty, and whenever you type a character 'i' on it, it reverses the string that you have written.
Scramble String
We can scramble a string s to get a string t using the following algorithm: Given two strings s1 and s2 of the same length, return true if s2 is a scrambled string of s1,...
Minimize the Total Price of the Trips
There exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1.
Minimum Number of Steps to Make Two Strings Anagram II
You are given two strings s and t.
Unique Paths II
You are given an m x n integer array grid.
Count Cells in Overlapping Horizontal and Vertical Substrings
You are given an m x n matrix grid consisting of characters and a string pattern.
Divide an Array Into Subarrays With Minimum Cost II
You are given a 0-indexed array of integers nums of length n, and two positive integers k and dist.
Shortest Distance After Road Addition Queries II
You are given an integer n and a 2D integer array queries.
Find Closest Node to Given Two Nodes
You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge.
Valid Palindrome II
Given a string s, return true if the s can be palindrome after deleting at most one character from it.
Custom Sort String
You are given two strings order and s.
Print Words Vertically
Given a string s.
Minimum Time to Finish the Race
You are given a 0-indexed 2D integer array tires where tires[i] = [fi, ri] indicates that the ith tire can finish its xth successive lap in fi * ri(x-1) seconds.
Uncommon Words from Two Sentences
A sentence is a string of single-space separated words where each word consists only of lowercase letters.
Maximum Score Of Spliced Array
You are given two 0-indexed integer arrays nums1 and nums2, both of length n.
Sliding Window Median
The median is the middle value in an ordered integer list.
Partition Array Into Three Parts With Equal Sum
Given an array of integers arr, return true if we can partition the array into three non-empty parts with equal sums.
Adjacent Increasing Subarrays Detection I
Given an array nums of n integers and an integer k, determine whether there exist two adjacent subarrays of length k such that both subarrays are strictly increasing.
Decrease Elements To Make Array Zigzag
Given an array nums of integers, a move consists of choosing any element and decreasing it by 1.
Network Recovery Pathways
You are given a directed acyclic graph of n nodes numbered from 0 to n − 1.
Minimum Operations to Make Array Sum Divisible by K
You are given an integer array nums and an integer k.
Find the N-th Value After K Seconds
You are given two integers n and k.
Make a Square with the Same Color
You are given a 2D matrix grid of size 3 x 3 consisting only of characters 'B' and 'W'.
Toeplitz Matrix
Given an m x n matrix, return true if the matrix is Toeplitz.
Minimum Time to Remove All Cars Containing Illegal Goods
You are given a 0-indexed binary string s which represents a sequence of train cars.
Intersection of Two Arrays
Given two integer arrays nums1 and nums2, return an array of their intersection.
Shortest Unsorted Continuous Subarray
Given an integer array nums, you need to find one continuous subarray such that if you only sort this subarray in non-decreasing order, then the whole array will be sorted in...
Mice and Cheese
There are two mice and n different types of cheese, each type of cheese should be eaten by exactly one mouse.
N-Queens II
The n-queens puzzle is the problem of placing n queens on an n x n chessboard such that no two queens attack each other.
Maximum Candies Allocated to K Children
You are given a 0-indexed integer array candies.
Making A Large Island
You are given an n x n binary matrix grid.
Minimum Operations to Make Array Equal II
You are given two integer arrays nums1 and nums2 of equal length n and an integer k.
Number of Steps to Reduce a Number to Zero
Given an integer num, return the number of steps to reduce it to zero.
Find Minimum Time to Finish All Jobs
You are given an integer array jobs, where jobs[i] is the amount of time it takes to complete the ith job.
Maximum Element-Sum of a Complete Subset of Indices
You are given a 1-indexed array nums.
Find Champion I
There are n teams numbered from 0 to n - 1 in a tournament.
Account Balance After Rounded Purchase
Initially, you have a bank account balance of 100 dollars.
Find Missing Observations
You have observations of n + m 6-sided dice rolls with each face numbered from 1 to 6.
Construct the Minimum Bitwise Array II
You are given an array nums consisting of n prime integers.
Ambiguous Coordinates
We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)".
Matrix Diagonal Sum
Given a square matrix mat, return the sum of the matrix diagonals.
Longest Consecutive Sequence
Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
Find the Punishment Number of an Integer
Given a positive integer n, return the punishment number of n.
Maximum Points in an Archery Competition
Alice and Bob are opponents in an archery competition.
Merge Similar Items
You are given two 2D integer arrays, items1 and items2, representing two sets of items.
Minimum Falling Path Sum II
Given an n x n integer matrix grid, return the minimum sum of a falling path with non-zero shifts.
Sum of k-Mirror Numbers
A k-mirror number is a positive integer without leading zeros that reads the same both forward and backward in base-10 as well as in base-k.
Sum of All Odd Length Subarrays
Given an array of positive integers arr, return the sum of all possible odd-length subarrays of arr.
Generate a String With Characters That Have Odd Counts
Given an integer n, return a string with n characters such that each character in such string occurs an odd number of times.
Palindrome Partitioning
Given a string s, partition s such that every substring of the partition is a palindrome.
Count Common Words With One Occurrence
Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays.
Minimum Cost to Make at Least One Valid Path in a Grid
Given an m x n grid.
Find All Possible Stable Binary Arrays II
You are given 3 positive integers zero, one, and limit.
Basic Calculator II
Given a string s which represents an expression, evaluate this expression and return its value.
Number of Segments in a String
Given a string s, return the number of segments in the string.
Maximum Palindromes After Operations
You are given a 0-indexed string array words having length n and containing 0-indexed strings.
Minimum Impossible OR
You are given a 0-indexed integer array nums.
Closest Room
There is a hotel with n rooms.
Maximal Square
Given an m x n binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area.
Reformat Date
Given a date string in the form Day Month Year, where: Convert the date string to the format YYYY-MM-DD, where:
Count Special Integers
We call a positive integer special if all of its digits are distinct.
Maximum Building Height
You want to build n new buildings in a city.
Lexicographically Smallest String After Operations With Constraint
You are given a string s and an integer k.
Single Number II
Given an integer array nums where every element appears three times except for one, which appears exactly once.
Find Closest Person
You are given three integers x, y, and z, representing the positions of three people on a number line: Both Person 1 and Person 2 move toward Person 3 at the same speed.
Find K-th Smallest Pair Distance
The distance of a pair of integers a and b is defined as the absolute difference between a and b.
Flipping an Image
Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.
Arithmetic Subarrays
A sequence of numbers is called arithmetic if it consists of at least two elements, and the difference between every two consecutive elements is the same.
Number of Provinces
There are n cities.
Find the Prefix Common Array of Two Arrays
You are given two 0-indexed integer permutations A and B of length n.
Check if a Parentheses String Can Be Valid
A parentheses string is a non-empty string consisting only of '(' and ')'.
Maximum Nesting Depth of the Parentheses
Given a valid parentheses string s, return the nesting depth of s.
Can Convert String in K Moves
Given two strings s and t, your goal is to convert s into t in k moves or less.
Matchsticks to Square
You are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick.
Palindrome Number
Given an integer x, return true if x is a palindrome, and false otherwise.
Strictly Palindromic Number
An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromic.
Count Prime-Gap Balanced Subarrays
You are given an integer array nums and an integer k.
New 21 Game
Alice plays the following game, loosely based on the card game "21".
N-Repeated Element in Size 2N Array
You are given an integer array nums with the following properties: Return the element that is repeated n times.
Network Delay Time
You are given a network of n nodes, labeled from 1 to n.
Find Maximum Removals From Source String
You are given a string source of size n, a string pattern that is a subsequence of source, and a sorted integer array targetIndices that contains distinct numbers in the range [0,...
Longest Subarray With Maximum Bitwise AND
You are given an integer array nums of size n.
Trionic Array I
You are given an integer array nums of length n.
Integer to English Words
Convert a non-negative integer num to its English words representation.
Maximum Length of Repeated Subarray
Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays.
Binary Tree Paths
Return every root-to-leaf path in a binary tree as an arrow-joined string.
Abbreviating the Product of a Range
You are given two positive integers left and right with left <= right.
Odd String Difference
You are given an array of equal-length strings words.
Minimum Time to Revert Word to Initial State I
You are given a 0-indexed string word and an integer k.
The k-th Lexicographical String of All Happy Strings of Length n
A happy string is a string that: For example, strings "abc", "ac", "b" and "abcbabcbcb" are all happy strings and strings "aa", "baa" and "ababbc" are not happy strings.
Monotonic Array
An array is monotonic if it is either monotone increasing or monotone decreasing.
Create Maximum Number
You are given two integer arrays nums1 and nums2 of lengths m and n respectively.
Camelcase Matching
Given an array of strings queries and a string pattern, return a boolean array answer where answer[i] is true if queries[i] matches pattern, and false otherwise.
K Closest Points to Origin
Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane and an integer k, return the k closest points to the origin (0, 0).
Kth Smallest Element in a BST
Find the k-th smallest value stored in a binary search tree.
Greatest Common Divisor Traversal
You are given a 0-indexed integer array nums, and you are allowed to traverse between its indices.
Maximum Number of Integers to Choose From a Range I
You are given an integer array banned and two integers n and maxSum.
Minimum Jumps to Reach End via Prime Teleportation
You are given an integer array nums of length n.
Sum of Digits in Base K
Given an integer n (in base 10) and a base k, return the sum of the digits of n after converting n from base 10 to base k.
Maximum Number of Alloys
You are the owner of a company that creates alloys using various types of metals.
Count Largest Group
You are given an integer n.
Total Appeal of A String
The appeal of a string is the number of distinct characters found in the string.
Maximum Frequency After Subarray Operation
You are given an array nums of length n.
Sum of Largest Prime Substrings
Given a string s, find the sum of the 3 largest unique prime numbers that can be formed using any of its substrings.
K-Similar Strings
Strings s1 and s2 are k-similar (for some non-negative integer k) if we can swap the positions of two letters in s1 exactly k times so that the resulting string equals s2.
Remove Comments
Given a C++ program, remove comments from it.
Minimum Moves to Pick K Ones
You are given a binary array nums of length n, a positive integer k and a non-negative integer maxChanges.
Defuse the Bomb
You have a bomb to defuse, and your time is running out!
Champagne Tower
We stack glasses in a pyramid, where the first row has 1 glass, the second row has 2 glasses, and so on until the 100th row.
Maximum Profit in Job Scheduling
We have n jobs, where every job is scheduled to be done from startTime[i] to endTime[i], obtaining a profit of profit[i].
Number of Distinct Roll Sequences
You are given an integer n.
Total Cost to Hire K Workers
You are given a 0-indexed integer array costs where costs[i] is the cost of hiring the ith worker.
Task Scheduler II
You are given a 0-indexed array of positive integers tasks, representing tasks that need to be completed in order, where tasks[i] represents the type of the ith task.
Minimum Deletions for At Most K Distinct Characters
You are given a string s consisting of lowercase English letters, and an integer k.
Find the Pivot Integer
Given a positive integer n, find the pivot integer x such that: Return the pivot integer x.
Smallest Rotation with Highest Score
You are given an array nums.
A Number After a Double Reversal
Reversing an integer means to reverse all its digits.
Rotate Array
Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.
Maximum Difference Between Even and Odd Frequency I
You are given a string s consisting of lowercase English letters.
Shortest Subarray With OR at Least K II
You are given an array nums of non-negative integers and an integer k.
Rotate a Linked List
Rotate a singly-linked list to the right by k places, wrapping around as needed.
Determine the Winner of a Bowling Game
You are given two 0-indexed integer arrays player1 and player2, representing the number of pins that player 1 and player 2 hit in a bowling game, respectively.
Transpose Matrix
Given a 2D integer array matrix, return the transpose of matrix.
Find the Student that Will Replace the Chalk
There are n students in a class numbered from 0 to n - 1.
Find a Good Subset of the Matrix
You are given a 0-indexed m x n binary matrix grid.
Count Islands With Total Value Divisible by K
You are given an m x n matrix grid and a positive integer k.
Number of Changing Keys
You are given a 0-indexed string s typed by a user.
Maximum Number of Non-Overlapping Substrings
Given a string s of lowercase letters, you need to find the maximum number of non-empty substrings of s that meet the following conditions: Find the maximum number of substrings...
Find the Number of Ways to Place People I
You are given a 2D array points of size n x 2 representing integer coordinates of some points on a 2D plane, where points[i] = [xi, yi].
Maximum Product Subarray
Given an integer array nums, find a subarray that has the largest product, and return the product.
Buy Two Chocolates
You are given an integer array prices representing the prices of various chocolates in a store.
Subdomain Visit Count
A website domain "discuss.example.com" consists of various subdomains.
Day of the Year
Given a string date representing a Gregorian calendar date formatted as YYYY-MM-DD, return the day number of the year.
Fair Candy Swap
Alice and Bob have a different total number of candies.
Check if Word Can Be Placed In Crossword
You are given an m x n matrix board, representing the current state of a crossword puzzle.
Find the Minimum Number of Fibonacci Numbers Whose Sum Is K
Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k.
Smallest Palindromic Rearrangement II
You are given a palindromic string s and an integer k.
Number of Students Unable to Eat Lunch
The school cafeteria offers circular and square sandwiches at lunch break, referred to by numbers 0 and 1 respectively.
Unique Email Addresses
Every valid email consists of a local name and a domain name, separated by the '@' sign.
Zuma Game
You are playing a variation of the game Zuma.
Contain Virus
A virus is spreading rapidly, and your task is to quarantine the infected area by installing walls.
Find the Count of Numbers Which Are Not Special
You are given 2 positive integers l and r.
Minimum Number of Operations to Satisfy Conditions
You are given a 2D matrix grid of size m x n.
Valid Parenthesis String
Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid.
Minimum Additions to Make Valid String
Given a string word to which you can insert letters "a", "b" or "c" anywhere and any number of times, return the minimum number of letters that must be inserted so that word...
Find Longest Special Substring That Occurs Thrice I
You are given a string s that consists of lowercase English letters.
Continuous Subarrays
You are given a 0-indexed integer array nums.
Process String with Special Operations II
You are given a string s consisting of lowercase English letters and the special characters: '*', '#', and '%'.
Number of Days Between Two Dates
Write a program to count the number of days between two dates.
Find Servers That Handled Most Number of Requests
You have k servers numbered from 0 to k-1 that are being used to handle multiple requests simultaneously.
Count Prefix and Suffix Pairs II
You are given a 0-indexed string array words.
Maximum Path Quality of a Graph
There is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive).
Delete Operation for Two Strings
Given two strings word1 and word2, return the minimum number of steps required to make word1 and word2 the same.
Number of Squareful Arrays
An array is squareful if the sum of every pair of adjacent elements is a perfect square.
Reconstruct Itinerary
You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight.
Find Palindrome With Fixed Length
Given an integer array queries and a positive integer intLength, return an array answer where answer[i] is either the queries[i]th smallest positive palindrome of length intLength...
Maximum Number of Groups With Increasing Length
You are given a 0-indexed array usageLimits of length n.
Minimum Moves to Spread Stones Over Grid
You are given a 0-indexed 2D integer matrix grid of size 3 * 3, representing the number of stones in each cell.
Minimum Operations to Make Array Equal
You have an array arr of length n where arr[i] = (2 * i) + 1 for all valid values of i (i.e., 0 <= i < n).
Concatenated Divisibility
You are given an array of positive integers nums and a positive integer k.
Find the Power of K-Size Subarrays I
You are given an array of integers nums of length n and a positive integer k.
Power of Three
Given an integer n, return true if it is a power of three.
Maximize the Minimum Powered City
You are given a 0-indexed integer array stations of length n, where stations[i] represents the number of power stations in the ith city.
Maximize the Number of Target Nodes After Connecting Trees I
There exist two undirected trees with n and m nodes, with distinct labels in ranges [0, n - 1] and [0, m - 1], respectively.
Capacity To Ship Packages Within D Days
A conveyor belt has packages that must be shipped from one port to another within days days.
Count Vowels Permutation
Given an integer n, your task is to count how many strings of length n can be formed under the following rules: Since the answer may be too large, return it modulo 10^9 + 7.
Smallest Missing Genetic Value in Each Subtree
There is a family tree rooted at 0 consisting of n nodes numbered 0 to n - 1.
The Score of Students Solving Math Expression
You are given a string s that contains digits 0-9, addition symbols '+', and multiplication symbols '*' only, representing a valid math expression of single digit numbers (e.g.,...
Sum of Distances
You are given a 0-indexed integer array nums.
Maximum Erasure Value
You are given an array of positive integers nums and want to erase a subarray containing unique elements.
Maximum Product Difference Between Two Pairs
The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d).
Minimum Number of Operations to Make Arrays Similar
You are given two positive integer arrays nums and target, of the same length.
Minimum Remove to Make Valid Parentheses
Given a string s of '(' , ')' and lowercase English characters.
Combinations
Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n].
Remove Digit From Number to Maximize Result
You are given a string number representing a positive integer and a character digit.
Super Pow
Your task is to calculate ab mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.
Number of Wonderful Substrings
A wonderful string is a string where at most one letter appears an odd number of times.
Delivering Boxes from Storage to Ports
You have the task of delivering some boxes from storage to their ports using only one ship.
Maximum Strictly Increasing Cells in a Matrix
Given a 1-indexed m x n integer matrix mat, you can select any cell in the matrix as your starting cell.
Minimum Speed to Arrive on Time
You are given a floating-point number hour, representing the amount of time you have to reach the office.
Mean of Array After Removing Some Elements
Given an integer array arr, return the mean of the remaining integers after removing the smallest 5% and the largest 5% of the elements.
Maximum Running Time of N Computers
You have n computers.
Reverse Prefix of Word
Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive).
Minimum Score After Removals on a Tree
There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.
All Divisions With the Highest Score of a Binary Array
You are given a 0-indexed binary array nums of length n.
Removing Minimum and Maximum From Array
You are given a 0-indexed array of distinct integers nums.
Minimum Absolute Difference in Sliding Submatrix
You are given an m x n integer matrix grid and an integer k.
Find the Grid of Region Average
You are given m x n grid image which represents a grayscale image, where image[i][j] represents a pixel with intensity in the range [0..255].
Longest Duplicate Substring
Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times.
Nth Digit
Given an integer n, return the nth digit of the infinite integer sequence [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...].
Number of Ways to Assign Edge Weights I
There is an undirected tree with n nodes labeled from 1 to n, rooted at node 1.
Find Minimum Log Transportation Cost
You are given integers n, m, and k.
Longest Substring Of All Vowels in Order
A string is considered beautiful if it satisfies the following conditions: For example, strings "aeiou" and "aaaaaaeiiiioou" are considered beautiful, but "uaeio", "aeoiu", and...
Construct String With Repeat Limit
You are given a string s and an integer repeatLimit.
Number of Subarrays With GCD Equal to K
Given an integer array nums and an integer k, return the number of subarrays of nums where the greatest common divisor of the subarray's elements is k.
Chalkboard XOR Game
You are given an array of integers nums represents the numbers written on a chalkboard.
Maximum Difference Score in a Grid
You are given an m x n matrix grid consisting of positive integers.
Maximum Number of Consecutive Values You Can Make
You are given an integer array coins of length n which represents the n coins that you own.
Sum of Subarray Ranges
You are given an integer array nums.
Minimum Sum of Mountain Triplets II
You are given a 0-indexed array nums of integers.
Prison Cells After N Days
There are 8 prison cells in a row and each cell is either occupied or vacant.
Word Pattern
Given a pattern and a string s, find if s follows the same pattern.
Bulb Switcher II
There is a room with n bulbs labeled from 1 to n that all are turned on initially, and four buttons on the wall.
Expressive Words
Sometimes people repeat letters to represent extra feeling.
Check If Array Pairs Are Divisible by k
Given an array of integers arr of even length n and an integer k.
Find Substring With Given Hash Value
The hash of a 0-indexed string s of length k, given integers p and m, is computed using the following function: Where val(s[i]) represents the index of s[i] in the alphabet from...
Top K Frequent Words
Given an array of strings words and an integer k, return the k most frequent strings.
Fill a Special Grid
You are given a non-negative integer n representing a 2n x 2n grid.
Number of Ways to Select Buildings
You are given a 0-indexed binary string s which represents the types of buildings along a street where: As a city official, you would like to select 3 buildings for random...
Happy Students
You are given a 0-indexed integer array nums of length n where n is the total number of students in the class.
Count Complete Subarrays in an Array
You are given an array nums consisting of positive integers.
Find Building Where Alice and Bob Can Meet
You are given a 0-indexed array heights of positive integers, where heights[i] represents the height of the ith building.
Power of Two
Given an integer n, return true if it is a power of two.
Occurrences After Bigram
Given two strings first and second, consider occurrences in some text of the form "first second third", where second comes immediately after first, and third comes immediately...
Odd Even Jump
You are given an integer array arr.
Assign Elements to Groups with Constraints
You are given an integer array groups, where groups[i] represents the size of the ith group.
Similar String Groups
Two strings, X and Y, are considered similar if either they are identical or we can make them equivalent by swapping at most two letters (in distinct positions) within the string X.
Smallest Integer Divisible by K
Given a positive integer k, you need to find the length of the smallest positive integer n such that n is divisible by k, and n only contains the digit 1.
Reaching Points
Given four integers sx, sy, tx, and ty, return true if it is possible to convert the point (sx, sy) to the point (tx, ty) through some operations, or false otherwise.
Minimum Number of Swaps to Make the Binary String Alternating
Given a binary string s, return the minimum number of character swaps to make it alternating, or -1 if it is impossible.
Minimum Changes to Make K Semi-palindromes
Given a string s and an integer k, partition s into k substrings such that the letter changes needed to make each substring a semi-palindrome are minimized.
Longest Continuous Subarray With Absolute Diff Less Than or Equal to Limit
Given an array of integers nums and an integer limit, return the size of the longest non-empty subarray such that the absolute difference between any two elements of this subarray...
Clumsy Factorial
The factorial of a positive integer n is the product of all positive integers less than or equal to n.
Remove Outermost Parentheses
A valid parentheses string is either empty "", "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation.
Find All Possible Recipes from Given Supplies
You have information about n different recipes.
Find the Minimum Cost Array Permutation
You are given an array nums which is a permutation of [0, 1, 2, ..., n - 1].
Reverse String II
Given a string s and an integer k, reverse the first k characters for every 2k characters counting from the start of the string.
Remove Linked List Elements
Delete every node in a singly-linked list whose value matches a given target.
Create Sorted Array through Instructions
Given an integer array instructions, you are asked to create a sorted array from the elements in instructions.
Robot Bounded In Circle
On an infinite plane, a robot initially stands at (0, 0) and faces north.
Find Kth Bit in Nth Binary String
Given two positive integers n and k, the binary string Sn is formed as follows: Where + denotes the concatenation operation, reverse(x) returns the reversed string x, and...
Erect the Fence
You are given an array trees where trees[i] = [xi, yi] represents the location of a tree in the garden.
Course Schedule III
There are n different online courses numbered from 1 to n.
Minimum Operations to Make Array Values Equal to K
You are given an integer array nums and an integer k.
Robot Collisions
There are n 1-indexed robots, each having a position on a line, health, and movement direction.
Count Prefixes of a Given String
You are given a string array words and a string s, where words[i] and s comprise only of lowercase English letters.
Maximum Ascending Subarray Sum
Given an array of positive integers nums, return the maximum possible sum of an strictly increasing subarray in nums.
Longest Harmonious Subsequence
We define a harmonious array as an array where the difference between its maximum value and its minimum value is exactly 1.
Split Two Strings to Make Palindrome
You are given two strings a and b of the same length.
Reverse Only Letters
Given a string s, reverse the string according to the following rules: Return s after reversing it.
Number of Valid Words in a Sentence
A sentence consists of lowercase letters ('a' to 'z'), digits ('0' to '9'), hyphens ('-'), punctuation marks ('!', '.', and ','), and spaces (' ') only.
Minimum Cost to Cut a Stick
Given a wooden stick of length n units.
Largest Positive Integer That Exists With Its Negative
Given an integer array nums that does not contain any zeros, find the largest positive integer k such that -k also exists in the array.
Count Elements With Maximum Frequency
You are given an array nums consisting of positive integers.
Minimum Operations to Halve Array Sum
You are given an array nums of positive integers.
Missing Number
Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array.
Find the Lexicographically Largest String From the Box I
You are given a string word, and an integer numFriends.
Find the Minimum Possible Sum of a Beautiful Array
You are given positive integers n and target.
Longest Square Streak in an Array
You are given an integer array nums.
Sum of Subarray Minimums
Given an array of integers arr, find the sum of min(b), where b ranges over every (contiguous) subarray of arr.
Count the Number of Computer Unlocking Permutations
You are given an array complexity of length n.
Jump Game III
Given an array of non-negative integers arr, you are initially positioned at start index of the array.
Min Max Game
You are given a 0-indexed integer array nums whose length is a power of 2.
Find And Replace in String
You are given a 0-indexed string s that you must perform k replacement operations on.
Transform Array to All Equal Elements
You are given an integer array nums of size n containing only 1 and -1, and an integer k.
Advantage Shuffle
You are given two integer arrays nums1 and nums2 both of the same length.
Jump Game V
Given an array of integers arr and an integer d.
Minimum Number of Days to Make m Bouquets
You are given an integer array bloomDay, an integer m and an integer k.
Next Permutation
A permutation of an array of integers is an arrangement of its members into a sequence or linear order.
Find Greatest Common Divisor of Array
Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums.
Can Make Arithmetic Progression From Sequence
A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.
UTF-8 Validation
Given an integer array data representing the data, return whether it is a valid UTF-8 encoding (i.e.
Check Array Formation Through Concatenation
You are given an array of distinct integers arr and an array of integer arrays pieces, where the integers in pieces are distinct.
Find All Anagrams in a String
Given two strings s and p, return an array of all the start indices of p's anagrams in s.
Strong Password Checker
A password is considered strong if the below conditions are all met: Given a string password, return the minimum number of steps required to make password strong.
Count the Number of Ideal Arrays
You are given two integers n and maxValue, which are used to describe an ideal array.
Minimum Time to Complete All Tasks
There is a computer that can run an unlimited number of tasks at the same time.
Check if Binary String Has at Most One Segment of Ones
Given a binary string s without leading zeros, return true if s contains at most one contiguous segment of ones.
Longest Cycle in a Graph
You are given a directed graph of n nodes numbered from 0 to n - 1, where each node has at most one outgoing edge.
Decode XORed Permutation
There is an integer array perm that is a permutation of the first n positive integers, where n is always odd.
Min Cost to Connect All Points
You are given an array points representing integer coordinates of some points on a 2D-plane, where points[i] = [xi, yi].
Design a URL Shortener
Design a scalable short link service.
Find the Longest Valid Obstacle Course at Each Position
You want to build some obstacle courses.
Find All Good Strings
Given the strings s1 and s2 of size n and the string evil, return the number of good strings.
Symmetric Tree
Determine whether a binary tree is a mirror of itself around its center.
Count Array Pairs Divisible by K
Given a 0-indexed integer array nums of length n and an integer k, return the number of pairs (i, j) such that:
Cinema Seat Allocation
A cinema has n rows of seats, numbered from 1 to n and there are ten seats in each row, labelled from 1 to 10 as shown in the figure above.
Sum of Prefix Scores of Strings
You are given an array words of size n consisting of non-empty strings.
Squares of a Sorted Array
Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.
Count Good Numbers
A digit string is good if the digits (0-indexed) at even indices are even and the digits at odd indices are prime (2, 3, 5, or 7).
Maximum Segment Sum After Removals
You are given two 0-indexed integer arrays nums and removeQueries, both of length n.
Largest Element in an Array after Merge Operations
You are given a 0-indexed array nums consisting of positive integers.
Check Whether Two Strings are Almost Equivalent
Two strings word1 and word2 are considered almost equivalent if the differences between the frequencies of each letter from 'a' to 'z' between word1 and word2 is at most 3.
Queries on Number of Points Inside a Circle
You are given an array points where points[i] = [xi, yi] is the coordinates of the ith point on a 2D plane.
Find the Array Concatenation Value
You are given a 0-indexed integer array nums.
Number of Flowers in Full Bloom
You are given a 0-indexed 2D integer array flowers, where flowers[i] = [starti, endi] means the ith flower will be in full bloom from starti to endi (inclusive).
Maximum Total Reward Using Operations II
You are given an integer array rewardValues of length n, representing the values of rewards.
Find N Unique Integers Sum up to Zero
Given an integer n, return any array containing n unique integers such that they add up to 0.
Maximum Value of a String in an Array
The value of an alphanumeric string can be defined as: Given an array strs of alphanumeric strings, return the maximum value of any string in strs.
Beautiful Array
An array nums of length n is beautiful if: Given the integer n, return any beautiful array nums of length n.
Stone Removal Game
Alice and Bob are playing a game where they take turns removing stones from a pile, with Alice going first.
Maximum Points After Collecting Coins From All Nodes
There exists an undirected tree rooted at node 0 with n nodes labeled from 0 to n - 1.
Group Anagrams
Given an array of strings strs, group the anagrams together.
Number of Ways to Rearrange Sticks With K Sticks Visible
There are n uniquely-sized sticks whose lengths are integers from 1 to n.
Check if There is a Valid Path in a Grid
You are given an m x n grid.
Minimum Average Difference
You are given a 0-indexed integer array nums of length n.
Replace All Digits with Characters
You are given a 0-indexed string s that has lowercase English letters in its even indices and digits in its odd indices.
Max Chunks To Make Sorted II
You are given an integer array arr.
Consecutive Numbers Sum
Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers.
Minimum Array End
You are given two integers n and x.
Most Popular Video Creator
You are given two string arrays creators and ids, and an integer array views, all of length n.
Equal Rational Numbers
Given two strings s and t, each of which represents a non-negative rational number, return true if and only if they represent the same number.
Most Frequent Number Following Key In an Array
You are given a 0-indexed integer array nums.
Separate the Digits in an Array
Given an array of positive integers nums, return an array answer that consists of the digits of each integer in nums after separating them in the same order they appear in nums.
Best Sightseeing Pair
You are given an integer array values where values[i] represents the value of the ith sightseeing spot.
Kth Smallest Instructions
Bob is standing at cell (0, 0), and he wants to reach destination: (row, column).
Brick Wall
There is a rectangular brick wall in front of you with n rows of bricks.
Course Schedule II
There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.
Shortest Path to Get All Keys
You are given an m x n grid grid where: You start at the starting point and one move consists of walking one space in one of the four cardinal directions.
Most Visited Sector in a Circular Track
Given an integer n and an integer array rounds.
Find Words Containing Character
You are given a 0-indexed array of strings words and a character x.
Find All Lonely Numbers in the Array
You are given an integer array nums.
Parallel Courses III
You are given an integer n, which indicates that there are n courses labeled from 1 to n.
Maximize Sum Of Array After K Negations
Given an integer array nums and an integer k, modify the array in the following way: You should apply this process exactly k times.
Predict the Winner
You are given an integer array nums.
Modify Graph Edge Weights
You are given an undirected weighted connected graph containing n nodes labeled from 0 to n - 1, and an integer array edges where edges[i] = [ai, bi, wi] indicates that there is...
Partition Array for Maximum XOR and AND
You are given an integer array nums.
Evaluate Reverse Polish Notation
You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation.
Delete Columns to Make Sorted
You are given an array of n strings strs, all of the same length.
Count Pairs That Form a Complete Day II
Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day.
Minimum Number of Work Sessions to Finish the Tasks
There are n tasks assigned to you.
Permutation in String
Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise.
Nearest Exit from Entrance in Maze
You are given an m x n matrix maze (0-indexed) with empty cells (represented as '.') and walls (represented as '+').
Special Array I
An array is considered special if the parity of every pair of adjacent elements is different.
Number of Ways to Split Array
You are given a 0-indexed integer array nums of length n.
Maximum Score from Performing Multiplication Operations
You are given two 0-indexed integer arrays nums and multipliers of size n and m respectively, where n >= m.
Break a Palindrome
Given a palindromic string of lowercase English letters palindrome, replace exactly one character with any lowercase English letter so that the resulting string is not a...
Maximum Sum With at Most K Elements
You are given a 2D integer matrix grid of size n x m, an integer array limits of length n, and an integer k.
Minimum Adjacent Swaps to Reach the Kth Smallest Number
You are given a string num, representing a large integer, and an integer k.
Find the Maximum Length of Valid Subsequence I
A subsequence sub of nums with length x is called valid if it satisfies: Return the length of the longest valid subsequence of nums.
Shortest String That Contains Three Strings
If there are multiple such strings, return the lexicographically smallest one.
Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.
Construct the Minimum Bitwise Array I
You are given an array nums consisting of n prime integers.
Count the Number of Incremovable Subarrays I
You are given a 0-indexed array of positive integers nums.
Koko Eating Bananas
Koko loves to eat bananas.
Maximum Number of Ways to Partition an Array
You are given a 0-indexed integer array nums of length n.
Groups of Strings
You are given a 0-indexed array of strings words.
Maximum Containers on a Ship
You are given a positive integer n representing an n x n cargo deck on a ship.
Expression Add Operators
Given a string num that contains only digits and an integer target, return all possibilities to insert the binary operators '+', '-', and/or '*' between the digits of num so that...
Distinct Prime Factors of Product of Array
Given an array of positive integers nums, return the number of distinct prime factors in the product of the elements of nums.
Arranging Coins
You have n coins and you want to build a staircase with these coins.
Next Greater Element IV
You are given a 0-indexed array of non-negative integers nums.
Minimum Suffix Flips
You are given a 0-indexed binary string target of length n.
Matrix Cells in Distance Order
You are given four integers row, cols, rCenter, and cCenter.
Minimum Sum of Four Digit Number After Splitting Digits
You are given a positive integer num consisting of exactly four digits.
Check If Two String Arrays are Equivalent
Given two string arrays word1 and word2, return true if the two arrays represent the same string, and false otherwise.
Detonate the Maximum Bombs
You are given a list of bombs.
Neither Minimum nor Maximum
Given an integer array nums containing distinct positive integers, find and return any number from the array that is neither the minimum nor the maximum value in the array, or -1...
Largest Perimeter Triangle
Given an integer array nums, return the largest perimeter of a triangle with a non-zero area, formed from three of these lengths.
Longest Path With Different Adjacent Characters
You are given a tree (i.e.
Accounts Merge
Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] is a name, and the rest of the elements are emails...
Path In Zigzag Labelled Binary Tree
In an infinite binary tree where every node has two children, the nodes are labelled in row order.
Minimum Number of Removals to Make Mountain Array
You may recall that an array arr is a mountain array if and only if: Given an integer array nums, return the minimum number of elements to remove to make nums a mountain...
Image Smoother
An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight surrounding cells (i.e., the...
Shortest Impossible Sequence of Rolls
You are given an integer array rolls of length n and an integer k.
Max Difference You Can Get From Changing an Integer
You are given an integer num.
Count Operations to Obtain Zero
You are given two non-negative integers num1 and num2.
Minimum Index of a Valid Split
An element x of an integer array arr of length m is dominant if more than half the elements of arr have a value of x.
Number of Sets of K Non-Overlapping Line Segments
Given n points on a 1-D plane, where the ith point (from 0 to n-1) is at x = i, find the number of ways we can draw exactly k non-overlapping line segments such that each segment...
Number of Equivalent Domino Pairs
Given a list of dominoes, dominoes[i] = [a, b] is equivalent to dominoes[j] = [c, d] if and only if either (a == c and b == d), or (a == d and b == c) - that is, one domino can be...
Smallest Substring With Identical Characters II
You are given a binary string s of length n and an integer numOps.
Stone Game V
There are several stones arranged in a row, and each stone has an associated value which is an integer given in the array stoneValue.
Paint House III
There is a row of m houses in a small city, each house must be painted with one of the n colors (labeled from 1 to n), some houses that have been painted last summer should not be...
Check if a String Is an Acronym of Words
Given an array of strings words and a string s, determine if s is an acronym of words.
Find Latest Group of Size M
Given an array arr that represents a permutation of numbers from 1 to n.
Find Nearest Point That Has the Same X or Y Coordinate
You are given two integers, x and y, which represent your current location on a Cartesian grid: (x, y).
The Employee That Worked on the Longest Task
There are n employees, each with a unique id from 0 to n - 1.
Longest Non-decreasing Subarray From Two Arrays
You are given two 0-indexed integer arrays nums1 and nums2 of length n.
All Paths From Source to Target
Given a directed acyclic graph (DAG) of n nodes labeled from 0 to n - 1, find all possible paths from node 0 to node n - 1 and return them in any order.
Robot Return to Origin
There is a robot starting at the position (0, 0), the origin, on a 2D plane.
Replace Words
In English, we have a concept called root, which can be followed by some other word to form another longer word - let's call this word derivative.
Count Pairs of Points With Distance k
You are given a 2D integer array coordinates and an integer k, where coordinates[i] = [xi, yi] are the coordinates of the ith point in a 2D plane.
Insert Interval
You are given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith interval and intervals is sorted in...
Magical String
A magical string s consists of only '1' and '2' and obeys the following rules: The first few elements of s is s = "1221121221221121122……".
Card Flipping Game
You are given two 0-indexed integer arrays fronts and backs of length n, where the ith card has the positive integer fronts[i] printed on the front and backs[i] printed on the back.
Verbal Arithmetic Puzzle
Given an equation, represented by words on the left side and the result on the right side.
Minimum Incompatibility
You are given an integer array nums and an integer k.
Longest Substring Without Repeating Characters
Given a string s, find the length of the longest substring without duplicate characters.
Minimum Jumps to Reach Home
A certain bug's home is on the x-axis at position x.
Can You Eat Your Favorite Candy on Your Favorite Day?
You are given a (0-indexed) array of positive integers candiesCount where candiesCount[i] represents the number of candies of the ith type you have.
Find Indices With Index and Value Difference I
You are given a 0-indexed integer array nums having length n, an integer indexDifference, and an integer valueDifference.
Eat Pizzas!
You are given an integer array pizzas of size n, where pizzas[i] represents the weight of the ith pizza.
Goat Latin
You are given a string sentence that consist of words separated by spaces.
Stone Game II
Alice and Bob continue their games with piles of stones.
Maximum Value at a Given Index in a Bounded Array
You are given three positive integers: n, index, and maxSum.
Partition Equal Subset Sum
Given an integer array nums, return true if you can partition the array into two subsets such that the sum of the elements in both subsets is equal or false otherwise.
Reverse Substrings Between Each Pair of Parentheses
You are given a string s that consists of lower case English letters and brackets.
Count Covered Buildings
You are given a positive integer n, representing an n x n city.
Choose K Elements With Maximum Sum
You are given two integer arrays, nums1 and nums2, both of length n, along with a positive integer k.
Maximize the Number of Target Nodes After Connecting Trees II
There exist two undirected trees with n and m nodes, labeled from [0, n - 1] and [0, m - 1], respectively.
Furthest Point From Origin
You are given a string moves of length n consisting only of characters 'L', 'R', and '_'.
Maximum Total Reward Using Operations I
You are given an integer array rewardValues of length n, representing the values of rewards.
Identify the Largest Outlier in an Array
You are given an integer array nums.
Reorganize String
Given a string s, rearrange the characters of s so that any two adjacent characters are not the same.
Count Partitions With Max-Min Difference at Most K
You are given an integer array nums and an integer k.
Largest Odd Number in String
You are given a string num, representing a large integer.
Best Poker Hand
You are given an integer array ranks and a character array suits.
Moving Stones Until Consecutive
There are three stones in different positions on the X-axis.
Find the Minimum Area to Cover All Ones I
You are given a 2D binary array grid.
Find the K-Sum of an Array
You are given an integer array nums and a positive integer k.
Moving Stones Until Consecutive II
There are some stones in different positions on the X-axis.
Lexicographical Numbers
Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order.
Maximum Repeating Substring
For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence.
Minimum Consecutive Cards to Pick Up
You are given an integer array cards where cards[i] represents the value of the ith card.
Stone Game VIII
Alice and Bob take turns playing a game, with Alice starting first.
24 Game
You are given an integer array cards of length 4.
Decrypt String from Alphabet to Integer Mapping
You are given a string s formed by digits and '#'.
Burst Balloons
You are given n balloons, indexed from 0 to n - 1.
Count Substrings That Can Be Rearranged to Contain a String II
You are given two strings word1 and word2.
Count Sub Islands
You are given two m x n binary matrices grid1 and grid2 containing only 0's (representing water) and 1's (representing land).
Generate Tag for Video Caption
You are given a string caption representing the caption for a video.
The Earliest and Latest Rounds Where Players Compete
There is a tournament where n players are participating.
Modify the Matrix
Given a 0-indexed m x n integer matrix matrix, create a new 0-indexed matrix called answer.
Maximum Earnings From Taxi
There are n points on a road you are driving your taxi on.
Non-overlapping Intervals
Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals...
Maximum Sum of Two Non-Overlapping Subarrays
Given an integer array nums and two integers firstLen and secondLen, return the maximum sum of elements in two non-overlapping subarrays with lengths firstLen and secondLen.
Minimum Sideway Jumps
There is a 3 lane road of length n that consists of n + 1 points labeled from 0 to n.
Maximum Candies You Can Get from Boxes
You have n boxes labeled from 0 to n - 1.
Partition Array into Two Equal Product Subsets
You are given an integer array nums containing distinct positive integers and an integer target.
Longest Nice Substring
A string s is nice if, for every letter of the alphabet that s contains, it appears both in uppercase and lowercase.
Longest Absolute File Path
Suppose we have a file system that stores both files and directories.
Shift 2D Grid
Given a 2D grid of size m x n and an integer k.
Numbers With Same Consecutive Differences
Given two integers n and k, return an array of all the integers of length n where the difference between every two consecutive digits is k.
Count Subarrays With Fixed Bounds
You are given an integer array nums and two integers minK and maxK.
Diagonal Traverse II
Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.
Maximum Product of the Length of Two Palindromic Substrings
You are given a 0-indexed string s and are tasked with finding two non-intersecting palindromic substrings of odd length such that the product of their lengths is maximized.
Split Message Based on Limit
You are given a string, message, and a positive integer, limit.
Number of Strings That Appear as Substrings in Word
Given an array of strings patterns and a string word, return the number of strings in patterns that exist as a substring in word.
Find the Original Typed String II
Alice is attempting to type a specific string on her computer.
Magic Squares In Grid
A 3 x 3 magic square is a 3 x 3 grid filled with distinct numbers from 1 to 9 such that each row, column, and both diagonals all have the same sum.
Unique Number of Occurrences
Given an array of integers arr, return true if the number of occurrences of each value in the array is unique or false otherwise.
Sum of K Subarrays With Length at Least M
You are given an integer array nums and two integers, k and m.
Find K Closest Elements
Given a sorted integer array arr, two integers k and x, return the k closest integers to x in the array.
Minimize Deviation in Array
You are given an array nums of n positive integers.
Find the K-th Character in String Game I
Alice and Bob are playing a game.
Block Placement Queries
There exists an infinite number line, with its origin at 0 and extending towards the positive x-axis.
Maximum Genetic Difference Query
There is a rooted tree consisting of n nodes numbered 0 to n - 1.
Sum of Subsequence Widths
The width of a sequence is the difference between the maximum and minimum elements in the sequence.
Path Existence Queries in a Graph II
You are given an integer n representing the number of nodes in a graph, labeled from 0 to n - 1.
Happy Number
Write an algorithm to determine if a number n is happy.
Find Two Non-overlapping Sub-arrays Each With Target Sum
You are given an array of integers arr and an integer target.
Maximum Score of a Node Sequence
There is an undirected graph with n nodes, numbered from 0 to n - 1.
Maximum Absolute Sum of Any Subarray
You are given an integer array nums.
Count Beautiful Numbers
You are given two positive integers, l and r.
Check If Digits Are Equal in String After Operations I
You are given a string s consisting of digits.
Count Non-Decreasing Subarrays After K Operations
You are given an array nums of n integers and an integer k.
Longest Unequal Adjacent Groups Subsequence I
You are given a string array words and a binary array groups both of length n.
Find Winner on a Tic Tac Toe Game
Tic-tac-toe is played by two players A and B on a 3 x 3 grid.
Counting Bits
Given an integer n, return an array ans of length n + 1 such that for each i (0 <= i <= n), ans[i] is the number of 1's in the binary representation of i.
Count Special Triplets
You are given an integer array nums.
Maximum Gap
Given an integer array nums, return the maximum difference between two successive elements in its sorted form.
Maximum Sum Queries
You are given two 0-indexed integer arrays nums1 and nums2, each of length n, and a 1-indexed 2D array queries where queries[i] = [xi, yi].
Minimum Moves to Capture The Queen
There is a 1-indexed 8 x 8 chessboard containing 3 pieces.
Find Beautiful Indices in the Given Array I
You are given a 0-indexed string s, a string a, a string b, and an integer k.
Minimum Length of String After Operations
You are given a string s.
Minimum Operations to Exceed Threshold Value I
You are given a 0-indexed integer array nums, and an integer k.
Divisor Game
Alice and Bob take turns playing a game, with Alice starting first.
Minimum Number of Operations to Make X and Y Equal
You are given two positive integers x and y.
Redundant Connection
In this problem, a tree is an undirected graph that is connected and has no cycles.
K-diff Pairs in an Array
Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array.
Find a Value of a Mysterious Function Closest to Target
Winston was given the above mysterious function func.
Maximum Number of Pairs in Array
You are given a 0-indexed integer array nums.
Count Distinct Numbers on Board
You are given a positive integer n, that is initially placed on a board.
Check if an Original String Exists Given Two Encoded Strings
An original string, consisting of lowercase English letters, can be encoded by the following steps: For example, one way to encode an original string "abcdefghijklmnop" might be:...
Minimum Common Value
Given two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays.
Find Maximum Area of a Triangle
You are given a 2D array coords of size n x 2, representing the coordinates of n points in an infinite Cartesian plane.
Constrained Subsequence Sum
Given an integer array nums and an integer k, return the maximum sum of a non-empty subsequence of that array such that for every two consecutive integers in the subsequence,...
Simplified Fractions
Given an integer n, return a list of all simplified fractions between 0 and 1 (exclusive) such that the denominator is less-than-or-equal-to n.
Stone Game VII
Alice and Bob take turns playing a game, with Alice starting first.
Count Number of Possible Root Nodes
Alice has an undirected tree with n nodes labeled from 0 to n - 1.
Grid Game
You are given a 0-indexed 2D array grid of size 2 x n, where grid[r][c] represents the number of points at position (r, c) on the matrix.
Paint House IV
You are given an even integer n representing the number of houses arranged in a straight line, and a 2D array cost of size n x 3, where cost[i][j] represents the cost of painting...
Check if Matrix Is X-Matrix
A square matrix is said to be an X-Matrix if both of the following conditions hold: Given a 2D integer array grid of size n x n representing a square matrix, return true if grid...
Maximum Multiplication Score
You are given an integer array a of size 4 and another integer array b of size at least 4.
Count Subarrays With Score Less Than K
The score of an array is defined as the product of its sum and its length.
Minimized Maximum of Products Distributed to Any Store
You are given an integer n indicating there are n specialty retail stores.
Best Time to Buy and Sell Stock IV
You are given an integer array prices where prices[i] is the price of a given stock on the ith day, and an integer k.
Roman to Integer
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Possible Bipartition
We want to split a group of n people (labeled from 1 to n) into two groups of any size.
Change Minimum Characters to Satisfy One of Three Conditions
You are given two strings a and b that consist of lowercase letters.
Minimum Swaps to Make Strings Equal
You are given two strings s1 and s2 of equal length consisting of letters "x" and "y" only.
Check If Word Is Valid After Substitutions
Given a string s, determine if it is valid.
Guess Number Higher or Lower II
We are playing the Guessing Game.
Count Nice Pairs in an Array
You are given an array nums that consists of non-negative integers.
Bulls and Cows
You are playing the Bulls and Cows game with your friend.
Apply Operations to Make Sum of Array Greater Than or Equal to k
You are given a positive integer k.
Find the Number of Copy Arrays
You are given an array original of length n and a 2D array bounds of length n x 2, where bounds[i] = [ui, vi].
Minimum Sum of Squared Difference
You are given two positive 0-indexed integer arrays nums1 and nums2, both of length n.
Minimum Cost to Make Array Equalindromic
You are given a 0-indexed integer array nums having length n.
Minimum Number of Operations to Make All Array Elements Equal to 1
You are given a 0-indexed array nums consisiting of positive integers.
Maximize the Number of Partitions After Operations
You are given a string s and an integer k.
Find All Duplicates in an Array
Given an integer array nums of length n where all the integers of nums are in the range [1, n] and each integer appears at most twice, return an array of all the integers that...
Critical Connections in a Network
There are n servers numbered from 0 to n - 1 connected by undirected server-to-server connections forming a network where connections[i] = [ai, bi] represents a connection between...
Maximum Sum Obtained of Any Permutation
We have an array of integers, nums, and an array of requests where requests[i] = [starti, endi].
Left and Right Sum Differences
You are given a 0-indexed integer array nums of size n.
Maximum Good Subtree Score
You are given an undirected tree rooted at node 0 with n nodes numbered from 0 to n - 1.
Reach End of Array With Max Score
You are given an integer array nums of length n.
Kth Smallest Path XOR Sum
You are given an undirected tree rooted at node 0 with n nodes numbered from 0 to n - 1.
Maximize Subarray GCD Score
You are given an array of positive integers nums and an integer k.
Merge Intervals
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals...
Longest Uncommon Subsequence II
Given an array of strings strs, return the length of the longest uncommon subsequence between them.
The Latest Time to Catch a Bus
You are given a 0-indexed integer array buses of length n, where buses[i] represents the departure time of the ith bus.
Maximum Number of Fish in a Grid
You are given a 0-indexed 2D matrix grid of size m x n, where (r, c) represents: A fisher can start at any water cell (r, c) and can do the following operations any number of...
Divide Nodes Into the Maximum Number of Groups
You are given a positive integer n representing the number of nodes in an undirected graph.
Convert the Temperature
You are given a non-negative floating point number rounded to two decimal places celsius, that denotes the temperature in Celsius.
Longest Binary Subsequence Less Than or Equal to K
You are given a binary string s and a positive integer k.
Score After Flipping Matrix
You are given an m x n binary matrix grid.
Count the Number of Complete Components
You are given an integer n.
Check Divisibility by Digit Sum and Product
You are given a positive integer n.
Valid Number
Given a string s, return whether s is a valid number.
Longest Word in Dictionary
Given an array of strings words representing an English Dictionary, return the longest word in words that can be built one character at a time by other words in words.
Threshold Majority Queries
You are given an integer array nums of length n and an array queries, where queries[i] = [li, ri, thresholdi].
Minimum Swaps to Group All 1's Together II
A swap is defined as taking two distinct positions in an array and swapping the values in them.
Palindrome Pairs
You are given a 0-indexed array of unique strings words.
Two Furthest Houses With Different Colors
There are n houses evenly lined up on the street, and each house is beautifully painted.
Find Products of Elements of Big Array
The powerful array of a non-negative integer x is defined as the shortest sorted array of powers of two that sum up to x.
Max Points on a Line
Given an array of points where points[i] = [xi, yi] represents a point on the X-Y plane, return the maximum number of points that lie on the same straight line.
Build Array Where You Can Find The Maximum Exactly K Comparisons
You are given three integers n, m and k.
Shuffle String
You are given a string s and an integer array indices of the same length.
Wiggle Subsequence
A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative.
Maximum Number of Subsequences After One Inserting
You are given a string s consisting of uppercase English letters.
Check if Numbers Are Ascending in a Sentence
A sentence is a list of tokens separated by a single space with no leading or trailing spaces.
Relative Ranks
You are given an integer array score of size n, where score[i] is the score of the ith athlete in a competition.
Make Costs of Paths Equal in a Binary Tree
You are given an integer n representing the number of nodes in a perfect binary tree consisting of nodes numbered from 1 to n.
Number of Ways to Divide a Long Corridor
Along a long library corridor, there is a line of seats and decorative plants.
Find the Sum of Subsequence Powers
You are given an integer array nums of length n, and a positive integer k.
4Sum II
Given four integer arrays nums1, nums2, nums3, and nums4 all of length n, return the number of tuples (i, j, k, l) such that:
Removing Stars From a String
You are given a string s, which contains stars *.
Minimum Absolute Difference Queries
The minimum absolute difference of an array a is defined as the minimum value of |a[i] - a[j]|, where 0 <= i < j < a.length and a[i] != a[j].
Check if DFS Strings Are Palindromes
You are given a tree rooted at node 0, consisting of n nodes numbered from 0 to n - 1.
Split Array Largest Sum
Given an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized.
Find Special Substring of Length K
You are given a string s and an integer k.
Sign of the Product of an Array
Implement a function signFunc(x) that returns: You are given an integer array nums.
Backspace String Compare
Given two strings s and t, return true if they are equal when both are typed into empty text editors.
Count Negative Numbers in a Sorted Matrix
Given a m x n matrix grid which is sorted in non-increasing order both row-wise and column-wise, return the number of negative numbers in grid.
Check if Move is Legal
You are given a 0-indexed 8 x 8 grid board, where board[r][c] represents the cell (r, c) on a game board.
Number of Smooth Descent Periods of a Stock
You are given an integer array prices representing the daily price history of a stock, where prices[i] is the stock price on the ith day.
Rearranging Fruits
You have two fruit baskets containing n fruits each.
Find All K-Distant Indices in an Array
You are given a 0-indexed integer array nums and two integers key and k.
Evaluate Division
You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i].
Relative Sort Array
Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1.
Sort an Array
Given an array of integers nums, sort the array in ascending order and return it.
Score of a String
You are given a string s.
Maximum Points Tourist Can Earn
You are given two integers, n and k, along with two 2D integer arrays, stayScore and travelScore.
Different Ways to Add Parentheses
Given a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators.
Make the XOR of All Segments Equal to Zero
You are given an array nums and an integer k.
Number of Ways of Cutting a Pizza
Given a rectangular pizza represented as a rows x cols matrix containing the following characters: 'A' (an apple) and '.' (empty cell) and given the integer k.
Split Array into Consecutive Subsequences
You are given an integer array nums that is sorted in non-decreasing order.
First Letter to Appear Twice
Given a string s consisting of lowercase English letters, return the first letter to appear twice.
Binary Tree Level Order Traversal
Add a queue-based level order (breadth-first) traversal to BinTree, visiting the sample tree one level at a time.
Find the Count of Monotonic Pairs I
You are given an array of positive integers nums of length n.
Count Ways to Make Array With Product
You are given a 2D integer array, queries.
Maximum XOR With an Element From Array
You are given an array nums consisting of non-negative integers.
Stamping the Grid
You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied).
Number of Ways to Paint N × 3 Grid
You have a grid of size n x 3 and you want to paint each cell of the grid with exactly one of the three colors: Red, Yellow, or Green while making sure that no two adjacent cells...
Prime Arrangements
Return the number of permutations of 1 to n so that prime numbers are at prime indices (1-indexed.) (Recall that an integer is prime if and only if it is greater than 1, and...
Minimum Obstacle Removal to Reach Corner
You are given a 0-indexed 2D integer array grid of size m x n.
Valid Anagram
Given two strings s and t, return true if t is an anagram of s, and false otherwise.
Kth Missing Positive Number
Given an array arr of positive integers sorted in a strictly increasing order, and an integer k.
Minimum Space Wasted From Packaging
You have n packages that you are trying to place in boxes, one package in each box.
Maximize Score of Numbers in Ranges
You are given an array of integers start and an integer d, representing n intervals [start[i], start[i] + d].
Count Number of Maximum Bitwise-OR Subsets
Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the maximum bitwise OR.
Kth Smallest Amount With Single Denomination Combination
You are given an integer array coins representing coins of different denominations and an integer k.
Collecting Chocolates
You are given a 0-indexed integer array nums of size n representing the cost of collecting different chocolates.
Combination Sum IV
Given an array of distinct integers nums and a target integer target, return the number of possible combinations that add up to target.
Minimize the Difference Between Target and Chosen Elements
You are given an m x n integer matrix mat and an integer target.
Check If a Word Occurs As a Prefix of Any Word in a Sentence
Given a sentence that consists of some words separated by a single space, and a searchWord, check if searchWord is a prefix of any word in sentence.
Minimum Interval to Include Each Query
You are given a 2D integer array intervals, where intervals[i] = [lefti, righti] describes the ith interval starting at lefti and ending at righti (inclusive).
Find All Numbers Disappeared in an Array
Given an array nums of n integers where nums[i] is in the range [1, n], return an array of all the integers in the range [1, n] that do not appear in nums.
Count Total Number of Colored Cells
There exists an infinitely large two-dimensional grid of uncolored unit cells.
Minimum Adjacent Swaps for K Consecutive Ones
You are given an integer array, nums, and an integer k.
Reconstruct Original Digits from English
Given a string s containing an out-of-order English representation of digits 0-9, return the digits in ascending order.
Minimum Number of Pushes to Type Word II
You are given a string word containing lowercase English letters.
Sum of Good Numbers
Given an array of integers nums and an integer k, an element nums[i] is considered good if it is strictly greater than the elements at indices i - k and i + k (if those indices...
Cyclically Rotating a Grid
You are given an m x n integer matrix grid, where m and n are both even integers, and an integer k.
Convert 1D Array Into 2D Array
You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n.
Reverse Words in a String III
Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Number of Senior Citizens
You are given a 0-indexed array of strings details.
Words Within Two Edits of Dictionary
You are given two string arrays, queries and dictionary.
Circular Array Loop
You are playing a game involving a circular array of non-zero integers nums.
Minimum Score Triangulation of Polygon
You have a convex n-sided polygon where each vertex has an integer value.
Maximum Product After K Increments
You are given an array of non-negative integers nums and an integer k.
Permutations II
Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.
Last Day Where You Can Still Cross
There is a 1-based binary matrix where 0 represents land and 1 represents water.
Validate Stack Sequences
Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty...
Find the Maximum Number of Fruits Collected
There is a game dungeon comprised of n x n rooms arranged in a grid.
Count Subarrays Where Max Element Appears at Least K Times
You are given an integer array nums and a positive integer k.
Apply Discount to Prices
A sentence is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign '$'.
Pairs of Songs With Total Durations Divisible by 60
You are given a list of songs where the ith song has a duration of time[i] seconds.
Number of Longest Increasing Subsequence
Given an integer array nums, return the number of longest increasing subsequences.
Row With Maximum Ones
Given a m x n binary matrix mat, find the 0-indexed position of the row that contains the maximum count of ones, and the number of ones in that row.
Grid Teleportation Traversal
You are given a 2D character grid matrix of size m x n, represented as an array of strings, where matrix[i][j] represents the cell at the intersection of the ith row and jth column.
Unit Conversion I
There are n types of units indexed from 0 to n - 1.
Longest Increasing Subsequence
Given an integer array nums, return the length of the longest strictly increasing subsequence.
Count the Number of Good Partitions
You are given a 0-indexed array nums consisting of positive integers.
Number of Pairs Satisfying Inequality
You are given two 0-indexed integer arrays nums1 and nums2, each of size n, and an integer diff.
Count Number of Texts
Alice is texting Bob using her phone.
Count Substrings That Differ by One Character
Given two strings s and t, find the number of ways you can choose a non-empty substring of s and replace a single character by a different character such that the resulting...
Shortest Uncommon Substring in an Array
You are given an array arr of size n consisting of non-empty strings.
How StringBuilder Works — API Cheat Sheet
No exercise here — how to build up a string efficiently in a loop across Java, C#, Python, and JavaScript/TypeScript, without accidentally writing O(n^2) code.
Square Every Element In Place
Practice raw array basics: fixed-size indexing, iteration, and in-place mutation.
Get All Root-to-Leaf Paths
Return every root-to-leaf path in a binary tree as a list of node values, instead of an arrow-joined string.
Delete a Node in a Binary Search Tree
Remove the node with a given value from a binary search tree while preserving its ordering property.
How Dynamic Lists Work — API Cheat Sheet
No exercise here — Java's ArrayList and C#'s List<T> side by side, the two languages here with a resizable-list type distinct from a raw array.
How Hash Sets Work — API Cheat Sheet
No exercise here — add/contains/remove across Java, C#, Python, and JavaScript/TypeScript, for the "have I seen this before" pattern that shows up everywhere.
Factorial with Recursion
Practice writing a recursive function with a clear base case and recursive case.
Build a Repeated, Joined String
Practice building a string incrementally (StringBuilder/append) instead of repeated concatenation.
How Queues Work — API Cheat Sheet
No exercise here — enqueue/dequeue across Java, C#, Python, and JavaScript/TypeScript, and the O(n) trap that catches people using the wrong structure.
Print Left View of a Binary Tree
Print the first node visible at each level of the sample tree, extending level order traversal with a single boolean flag.
Merge Two Sorted Linked Lists
Splice two sorted singly-linked lists together into a single sorted list.
Swap Nodes in Pairs
Swap every two adjacent nodes in a singly-linked list and return the new head.
How Priority Queues (Heaps) Work — API Cheat Sheet
No exercise here — how to get a min-heap or max-heap in Java, C#, Python, and JavaScript/TypeScript, since only two of these languages ship one built in.
Lowest Common Ancestor in a BST
Find the lowest common ancestor of two given values in a binary search tree, using the tree's ordering to avoid a generic tree search.
Valid Parentheses
Determine if a string of brackets is properly matched and nested.
Search in a Binary Search Tree
Find the node with a given value in a binary search tree and return the subtree rooted there.
K-th Smallest Unique Value
Practice using a sorted set (TreeSet/SortedSet) to keep values unique and in order.
How Stacks Work — API Cheat Sheet
No exercise here — push/pop/peek across Java, C#, Python, and JavaScript/TypeScript, and which type to actually use in each language.
Odd-Even Linked List
Regroup a singly-linked list so all odd-positioned nodes come before all even-positioned nodes.
Two Sum
Find two numbers in an array that add up to a target value.
Convert a Sorted Array to a Balanced BST
Build a height-balanced binary search tree from an array sorted in ascending order.
Reverse a Linked List
Reverse a singly-linked list in place and return the reversed list.
Serve the First K Customers in Line
Practice using a queue (Queue/Deque) to process items in first-in, first-out order.
Range Sum of a BST
Sum every node value in a binary search tree that falls within a given inclusive range.
Minimum Absolute Difference in a BST
Find the smallest absolute difference between the values of any two distinct nodes in a binary search tree.
How Loops & Conditionals Work — Syntax Cheat Sheet
No exercise here — for/while/switch syntax side by side across Java, C#, Python, and JavaScript/TypeScript, for when you're rusty in a language you don't use daily.
Middle of the Linked List
Find the value stored in the middle node of a singly-linked list in a single pass.