Questions

Filter by topic, difficulty, company, or study path as the app grows.

Array · 1579String · 666Hash Table · 532Dynamic Programming · 519Math · 503Sorting · 388Greedy · 373Binary Search · 238Bit Manipulation · 215Matrix · 205Prefix Sum · 178Two Pointers · 164Simulation · 160Heap Priority Queue · 148Counting · 144
medium

Beautiful Arrangement

Suppose you have n integers labeled 1 through n.

hard

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.

medium

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.

medium

Least Number of Unique Integers after K Removals

Given an array of integers arr and an integer k.

medium

Flip Columns For Maximum Number of Equal Rows

You are given an m x n binary matrix matrix.

medium

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.

hard

Stone Game III

Alice and Bob continue their games with piles of stones.

easy

Construct the Rectangle

A web developer needs to know how to design a web page's size.

hard

Subarrays Distinct Element Sum of Squares II

You are given a 0-indexed integer array nums.

easy

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.

medium

Generate Parentheses

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

hard

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.

medium

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...

easy

Find Closest Number to Zero

Given an integer array nums of size n, return the number with the value closest to 0 in nums.

medium

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.

medium

Sum in a Matrix

You are given a 0-indexed 2D integer array nums.

medium

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:

medium

Count Triplets That Can Form Two Arrays of Equal XOR

Given an array of integers arr.

easy

Single Number

Given a non-empty array of integers nums, every element appears twice except for one.

medium

The kth Factor of n

You are given two positive integers n and k.

medium

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...

hard

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.

medium

Broken Calculator

There is a broken calculator that has the integer startValue on its display initially.

medium

Maximum Swap

You are given an integer num.

medium

Alternating Groups II

There is a circle of red and blue tiles.

medium

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.

medium

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.

medium

Longest Palindrome by Concatenating Two Letter Words

You are given an array of strings words.

medium

Compact Object

Given an object or array obj, return a compact object.

easy

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.

medium

Determine the Minimum Sum of a k-avoiding Array

You are given two integers, n and k.

easy

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.

medium

Build an Array With Stack Operations

You are given an integer array target and an integer n.

medium

Reverse Words in a String

Given an input string s, reverse the order of the words.

medium

Count Beautiful Substrings I

You are given a string s and a positive integer k.

medium

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.

medium

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.

medium

Right Triangles

You are given a 2D boolean matrix grid.

easy

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.

easy

Get Maximum in Generated Array

You are given an integer n.

hard

Number of Different Subsequences GCDs

You are given an array nums that consists of positive integers.

easy

Check if One String Swap Can Make Strings Equal

You are given two strings s1 and s2 of equal length.

hard

Find the Count of Monotonic Pairs II

You are given an array of positive integers nums of length n.

easy

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.

medium

Minimum Increment to Make Array Unique

You are given an integer array nums.

easy

Is Object Empty

Given an object or an array, return if it is empty.

easy

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...

hard

Maximum Score From Grid Operations

You are given a 2D matrix grid of size n x n.

medium

Minimum Flips to Make a OR b Equal to c

Given 3 positives numbers a, b and c.

hard

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.

easy

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.

medium

Watering Plants II

Alice and Bob want to water n plants in their garden.

medium

Bulb Switcher

There are n bulbs that are initially off.

medium

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.

easy

Find Common Elements Between Two Arrays

You are given two integer arrays nums1 and nums2 of sizes n and m, respectively.

easy

Sort the People

You are given an array of strings names, and an array heights that consists of distinct positive integers.

easy

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.

easy

Height Checker

A school is trying to take an annual photo of all the students.

medium

Pyramid Transition Matrix

You are stacking blocks to form a pyramid.

easy

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.

medium

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.

medium

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.

hard

Select Cells in Grid With Maximum Score

You are given a 2D matrix grid consisting of positive integers.

medium

Maximum Amount of Money Robot Can Earn

You are given an m x n grid.

easy

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.

easy

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...

medium

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.

medium

Number of Substrings With Only 1s

Given a binary string s, return the number of substrings with all characters 1's.

hard

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.

medium

Minimum Score of a Path Between Two Cities

You are given a positive integer n representing n cities numbered from 1 to n.

medium

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.

hard

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.

medium

Find Eventual Safe States

There is a directed graph of n nodes with each node labeled from 0 to n - 1.

easy

Increasing Decreasing String

You are given a string s.

medium

Count Number of Teams

There are n soldiers standing in a line.

medium

Maximum Points You Can Obtain from Cards

There are several cards arranged in a row, and each card has an associated number of points.

hard

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...

medium

Largest Sum of Averages

You are given an integer array nums and an integer k.

hard

Number of Good Paths

There is a tree (i.e.

hard

Find the Occurrence of First Almost Equal Substring

You are given two strings s and pattern.

hard

Maximum Product of Subsequences With an Alternating Sum Equal to K

You are given an integer array nums and two integers, k and limit.

medium

Minimum Levels to Gain More Points

You are given a binary array possible of length n.

medium

Count the Number of Houses at a Certain Distance I

You are given three positive integers n, x, and y.

medium

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.

hard

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.

medium

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.

medium

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.

medium

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.

medium

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.

medium

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.

hard

The Number of Good Subsets

You are given an integer array nums.

easy

Perfect Number

A perfect number is a positive integer that is equal to the sum of its positive divisors, excluding the number itself.

medium

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.

medium

Array With Elements Not Equal to Average of Neighbors

You are given a 0-indexed array nums of distinct integers.

easy

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...

medium

Spiral Matrix III

You start at the cell (rStart, cStart) of an rows x cols grid facing east.

medium

Maximum Sum of an Hourglass

You are given an m x n integer matrix grid.

medium

Range Sum of Sorted Subarray Sums

You are given the array nums consisting of n positive integers.

medium

Count Substrings Starting and Ending with Given Character

You are given a string s and a character c.

medium

Find the Integer Added to Array II

You are given two integer arrays nums1 and nums2.

medium

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.

medium

Maximum Matrix Sum

You are given an n x n integer matrix.

medium

Minimum Operations to Convert Number

You are given a 0-indexed integer array nums containing distinct numbers, an integer start, and an integer goal.

easy

Maximum Number of Operations With the Same Score I

You are given an array of integers nums.

hard

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.

medium

Count Words Obtained After Adding a Letter

You are given two 0-indexed arrays of strings startWords and targetWords.

easy

Smallest Range I

You are given an integer array nums and an integer k.

easy

Number of Even and Odd Bits

You are given a positive integer n.

medium

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).

easy

Jewels and Stones

You're given strings jewels representing the types of stones that are jewels, and stones representing the stones you have.

hard

Maximum Number of Groups Getting Fresh Donuts

There is a donuts shop that bakes donuts in batches of batchSize.

medium

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].

easy

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.

easy

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.

hard

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].

hard

Count Substrings Divisible By Last Digit

You are given a string s consisting of digits.

medium

Push Dominoes

There are n dominoes in a line, and we place each domino vertically upright.

medium

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...

medium

Compare Version Numbers

Given two version strings, version1 and version2, compare them.

hard

Arithmetic Slices II - Subsequence

Given an integer array nums, return the number of all the arithmetic subsequences of nums.

hard

Find the Number of Subsequences With Equal GCD

You are given an integer array nums.

hard

Jump Game IV

Given an array of integers arr, you are initially positioned at the first index of the array.

medium

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...

medium

Mark Elements on Array by Performing Queries

You are given a 0-indexed array nums of size n consisting of positive integers.

medium

Find the Kth Largest Integer in the Array

You are given an array of strings nums and an integer k.

hard

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.

easy

Build a Sorted, Deduplicated List

Practice using a dynamic list (ArrayList/List) to collect, dedupe, and sort values.

easy

Counter

Given an integer n, return a counter function.

medium

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.

easy

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...

easy

Check if The Number is Fascinating

You are given an integer n that consists of exactly 3 digits.

hard

Handling Sum Queries After Update

You are given two 0-indexed arrays nums1 and nums2 and a 2D array queries of queries.

medium

Maximum Ice Cream Bars

It is a sweltering summer day, and a boy wants to buy some ice cream bars.

medium

Number of People Aware of a Secret

On day 1, one person discovers a secret.

medium

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.

hard

Poor Pigs

There are buckets buckets of liquid, where exactly one of the buckets is poisonous.

easy

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.

medium

Calculate Score After Performing Instructions

You are given two arrays, instructions and values, both of size n.

medium

Maximum XOR for Each Query

You are given a sorted array nums of n non-negative integers and an integer maximumBit.

medium

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...

easy

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.

hard

Maximize Palindrome Length From Subsequences

You are given two strings, word1 and word2.

medium

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.

medium

Shifting Letters

You are given a string s of lowercase English letters and an integer array shifts of the same length.

easy

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.

hard

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...

medium

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.

medium

Shortest Distance After Road Addition Queries I

You are given an integer n and a 2D integer array queries.

hard

Longest Subsequence Repeated k Times

You are given a string s of length n, and an integer k.

easy

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.

easy

Find the Original Typed String I

Alice is attempting to type a specific string on her computer.

medium

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.

easy

Minimum Right Shifts to Sort the Array

You are given a 0-indexed array nums of length n containing distinct positive integers.

easy

Minimum Positive Sum Subarray

You are given an integer array nums and two integers l and r.

hard

Maximum Number of Tasks You Can Assign

You have n tasks and m workers.

hard

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.

easy

Sorting the Sentence

A sentence is a list of words that are separated by a single space with no leading or trailing spaces.

hard

K-th Smallest in Lexicographical Order

Given two integers n and k, return the kth lexicographically smallest integer in the range [1, n].

medium

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...

medium

Minimum Cost For Tickets

You have planned some train traveling one year in advance.

medium

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...

hard

Number of Ways to Wear Different Hats to Each Other

There are n people and 40 types of hats labeled from 1 to 40.

easy

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.

easy

Clear Digits

You are given a string s.

hard

Final Array State After K Multiplication Operations II

You are given an integer array nums, an integer k, and an integer multiplier.

medium

K-th Nearest Obstacle Queries

There is an infinite 2D plane.

medium

Minimum Cost to Make Arrays Identical

You are given two integer arrays arr and brr of length n, and an integer k.

medium

Minimum Deletions to Make String Balanced

You are given a string s consisting only of characters 'a' and 'b'​​​​.

medium

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.

easy

Find the Difference

You are given two strings s and t.

hard

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.

medium

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.

hard

Meeting Rooms III

You are given an integer n.

medium

Minimum Operations to Make the Integer Zero

You are given two integers num1 and num2.

medium

Water and Jug Problem

You are given two jugs with capacities x liters and y liters.

hard

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.

easy

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...

medium

Number of Ways to Reach a Position After Exactly k Steps

You are given two positive integers startPos and endPos.

medium

Palindromic Substrings

Given a string s, return the number of palindromic substrings in it.

hard

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.

hard

Partition Array Into Two Arrays to Minimize Sum Difference

You are given an integer array nums of 2 * n integers.

hard

Distribute Elements Into Two Arrays II

You are given a 1-indexed array of integers nums of length n.

easy

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.

hard

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).

easy

Minimum Average of Smallest and Largest Elements

You have an array of floating point numbers averages which is initially empty.

medium

Count Unguarded Cells in the Grid

You are given two integers m and n representing a 0-indexed m x n grid.

medium

Minimum Processing Time

You have a certain number of processors, each having 4 cores.

medium

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...

medium

Statistics from a Large Sample

You are given a large sample of integers in the range [0, 255].

medium

Number of Good Ways to Split a String

You are given a string s.

medium

Count Nodes With the Highest Score

There is a binary tree rooted at 0 consisting of n nodes.

medium

Longest Well-Performing Interval

We are given hours, a list of the number of hours worked per day for a given employee.

medium

Subsets II

Given an integer array nums that may contain duplicates, return all possible subsets (the power set).

medium

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...

hard

Collect Coins in a Tree

There exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1.

medium

Partition Array to Minimize XOR

You are given an integer array nums and an integer k.

medium

Length of the Longest Subsequence That Sums to Target

You are given a 0-indexed array of integers nums, and an integer target.

easy

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.

medium

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...

hard

Find the Maximum Length of a Good Subsequence II

You are given an integer array nums and a non-negative integer k.

hard

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.

easy

Circular Sentence

A sentence is a list of words that are separated by a single space with no leading or trailing spaces.

medium

Beautiful Towers I

You are given an array heights of n integers representing the number of bricks in n consecutive towers.

medium

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...

medium

Largest Plus Sign

You are given an integer n.

medium

Maximum Total Importance of Roads

You are given an integer n denoting the number of cities in a country.

medium

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...

medium

Partition Array According to Given Pivot

You are given a 0-indexed integer array nums and an integer pivot.

hard

Minimum Cost to Hire K Workers

There are n workers.

medium

The Number of the Smallest Unoccupied Chair

There is a party where n friends numbered from 0 to n - 1 are attending.

hard

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.

easy

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].

medium

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.

medium

Ones and Zeroes

You are given an array of binary strings strs and two integers m and n.

medium

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.

easy

Valid Word

A word is considered valid if: You are given a string word.

medium

Verify Preorder Serialization of a Binary Tree

One way to serialize a binary tree is to use preorder traversal.

hard

Alternating Groups III

There are some red and blue tiles arranged circularly.

easy

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.

medium

Reach a Number

You are standing at position 0 on an infinite number line.

hard

Minimum Swaps To Make Sequences Increasing

You are given two integer arrays of the same length nums1 and nums2.

medium

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.

easy

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.

medium

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...

medium

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].

medium

Distant Barcodes

In a warehouse, there is a row of barcodes, where the ith barcode is barcodes[i].

easy

Minimum String Length After Removing Substrings

You are given a string s consisting only of uppercase English letters.

hard

Minimum Cost Good Caption

You are given a string caption of length n.

hard

Count All Valid Pickup and Delivery Options

Given n orders, each order consists of a pickup and a delivery service.

medium

Vowel Spellchecker

Given a wordlist, we want to implement a spellchecker that converts a query word into a correct word.

medium

Contiguous Array

Given a binary array nums, return the maximum length of a contiguous subarray with an equal number of 0 and 1.

medium

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).

medium

Maximum Subsequence Score

You are given two 0-indexed integer arrays nums1 and nums2 of equal length n and a positive integer k.

hard

Maximum Sum of Subsequence With Non-adjacent Elements

You are given an array nums consisting of integers.

medium

Car Pooling

There is a car with capacity empty seats.

hard

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.

easy

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).

easy

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.

easy

Count the Number of Special Characters I

You are given a string word.

medium

Count Vowel Strings in Ranges

You are given a 0-indexed array of strings words and a 2D array of integers queries.

medium

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,...

hard

Word Search II

Given an m x n board of characters and a list of strings words, return all words on the board.

easy

Longest Subsequence With Limited Sum

You are given an integer array nums of length n, and an integer array queries of length m.

hard

Reverse Subarray To Maximize Array Value

You are given an integer array nums.

easy

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.

medium

Delete Columns to Make Sorted II

You are given an array of n strings strs, all of the same length.

easy

Decode the Message

You are given the strings key and message, which represent a cipher key and a secret message, respectively.

medium

Maximum Number of Weeks for Which You Can Work

There are n projects numbered from 0 to n - 1.

hard

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).

hard

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...

easy

Find Center of Star Graph

There is an undirected star graph consisting of n nodes labeled from 1 to n.

easy

Minimum Element After Replacement With Digit Sum

You are given an integer array nums.

hard

Minimum Sum of Values by Dividing Array

You are given two arrays nums and andValues of length n and m respectively.

easy

Find the Peaks

You are given a 0-indexed array mountain.

hard

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 ...

medium

Search Suggestions System

You are given an array of strings products and a string searchWord.

medium

Most Stones Removed with Same Row or Column

On a 2D plane, we place n stones at some integer coordinate points.

hard

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.

hard

Add Edges to Make Degrees of All Nodes Even

There is an undirected graph consisting of n nodes numbered from 1 to n.

hard

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.

easy

Number of Common Factors

Given two positive integers a and b, return the number of common factors of a and b.

hard

Split the Array to Make Coprime Products

You are given a 0-indexed integer array nums of length n.

medium

Length of Longest Subarray With at Most K Frequency

You are given an integer array nums and an integer k.

hard

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...

easy

Binary Prefix Divisible By 5

You are given a binary array nums (0-indexed).

medium

Special Array II

An array is considered special if every pair of its adjacent elements contains two numbers with different parity.

medium

Minimum Number of Flips to Make Binary Grid Palindromic I

You are given an m x n binary matrix grid.

medium

Alphabet Board Path

On an alphabet board, we start at position (0, 0), corresponding to character board[0][0].

hard

Maximize Grid Happiness

You are given four integers, m, n, introvertsCount, and extrovertsCount.

medium

Maximum Value of an Ordered Triplet II

You are given a 0-indexed integer array nums.

medium

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.

medium

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.

medium

Sort the Jumbled Numbers

You are given a 0-indexed integer array mapping which represents the mapping rule of a shuffled decimal system.

medium

Count of Substrings Containing Every Vowel and K Consonants I

You are given a string word and a non-negative integer k.

easy

Count the Number of Consistent Strings

You are given a string allowed consisting of distinct characters and an array of strings words.

easy

To Lower Case

Given a string s, return the string after replacing every uppercase letter with the same lowercase letter.

medium

Find the Sequence of Strings Appeared on the Screen

You are given a string target.

medium

Reverse Integer

Given a signed 32-bit integer x, return x with its digits reversed.

hard

Minimum Cost to Make Array Equal

You are given two 0-indexed arrays nums and cost consisting each of n positive integers.

medium

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.

medium

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.

hard

Maximum Strong Pair XOR II

You are given a 0-indexed integer array nums.

medium

Out of Boundary Paths

There is an m x n grid with a ball.

hard

Maximum Value of K Coins From Piles

There are n piles of coins on a table.

medium

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.

easy

Shuffle the Array

Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].

easy

Reverse String

Write a function that reverses a string.

hard

Stamping The Sequence

You are given two strings stamp and target.

medium

Count Numbers with Unique Digits

Given an integer n, return the count of all numbers with unique digits, x, where 0 <= x < 10n.

medium

Is Graph Bipartite?

There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1.

medium

Append K Integers With Minimal Sum

You are given an integer array nums and an integer k.

easy

Add Binary

Given two binary strings a and b, return their sum as a binary string.

medium

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.

hard

Minimum Total Cost to Make Arrays Unequal

You are given two 0-indexed integer arrays nums1 and nums2, of equal length n.

hard

Brace Expansion II

Under the grammar given below, strings can represent a set of lowercase words.

easy

Number of Bit Changes to Make Two Integers Equal

You are given two positive integers n and k.

hard

Longest Common Subpath

There is a country of n cities numbered from 0 to n - 1.

medium

Diameter of Binary Tree

Find the length, in edges, of the longest path between any two nodes in a binary tree.

hard

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...

hard

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.

easy

Verifying an Alien Dictionary

In an alien language, surprisingly, they also use English lowercase letters, but possibly in a different order.

medium

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.

easy

Find the Sum of Encrypted Integers

You are given an integer array nums containing positive integers.

easy

Check if Array is Good

You are given an integer array nums.

medium

Mirror Reflection

There is a special square room with mirrors on each of the four walls.

easy

Consecutive Characters

The power of the string is the maximum length of a non-empty substring that contains only one unique character.

hard

Parsing A Boolean Expression

A boolean expression is an expression that evaluates to either true or false.

medium

High-Access Employees

You are given a 2D 0-indexed array of strings, access_times, with size n.

medium

Maximum Binary String After Change

You are given a binary string binary consisting of only 0's or 1's.

hard

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.

easy

Smallest Missing Integer Greater Than Sequential Prefix Sum

You are given a 0-indexed array of integers nums.

hard

Maximize the Minimum Game Score

You are given an array points of size n and an integer m.

easy

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.

medium

Count Number of Distinct Integers After Reverse Operations

You are given an array nums consisting of positive integers.

easy

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.

hard

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.

medium

Max Sum of a Pair With Equal Sum of Digits

You are given a 0-indexed array nums consisting of positive integers.

easy

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...

easy

Pass the Pillow

There are n people standing in a line labeled from 1 to n.

medium

Maximum Distance Between a Pair of Values

You are given two non-increasing 0-indexed integer arrays nums1​​​​​​ and nums2​​​​​​.

medium

Split Array Into Maximum Number of Subarrays

You are given an array nums consisting of non-negative integers.

medium

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.

hard

Number of Integers With Popcount-Depth Equal to K I

You are given two integers n and k.

easy

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.

medium

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.

medium

Find the Longest Semi-Repetitive Substring

You are given a digit string s that consists of digits from 0 to 9.

easy

Distribute Candies

Alice has n candies, where the ith candy is of type candyType[i].

medium

Minimum Insertions to Balance a Parentheses String

Given a parentheses string s containing only the characters '(' and ')'.

easy

Self Dividing Numbers

A self-dividing number is a number that is divisible by every digit it contains.

hard

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...

medium

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.

easy

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.

medium

House Robber IV

There are several consecutive houses along a street, each of which has some money inside.

hard

Minimum Number of Valid Strings to Form Target II

You are given an array of strings words and a string target.

easy

Maximum 69 Number

You are given a positive integer num consisting only of digits 6 and 9.

hard

Find the Largest Palindrome Divisible by K

You are given two positive integers n and k.

hard

Trionic Array II

You are given an integer array nums of length n.

medium

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.

hard

Maximum Number of Non-overlapping Palindrome Substrings

You are given a string s and a positive integer k.

medium

Maximal Network Rank

There is an infrastructure of n cities with some number of roads connecting these cities.

medium

Search a 2D Matrix II

Write an efficient algorithm that searches for a value target in an m x n integer matrix matrix.

easy

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.

hard

Count Complete Substrings

You are given a string word and an integer k.

hard

Building Boxes

You have a cubic storeroom where the width, length, and height of the room are all equal to n units.

easy

Base 7

Given an integer num, return a string of its base 7 representation.

hard

Nth Magical Number

A positive integer is magical if it is divisible by either a or b.

hard

Smallest Divisible Digit Product II

You are given a string num which represents a positive integer, and an integer t.

medium

Maximum Good Subarray Sum

You are given an array nums of length n and a positive integer k.

easy

Surface Area of 3D Shapes

You are given an n x n grid where you have placed some 1 x 1 x 1 cubes.

medium

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...

hard

Count Valid Paths in a Tree

There is an undirected tree with n nodes labeled from 1 to n.

medium

Maximum Size of a Set After Removals

You are given two 0-indexed integer arrays nums1 and nums2 of even length n.

medium

Get Biggest Three Rhombus Sums in a Grid

You are given an m x n integer matrix grid​​​.

medium

Longest Subsequence With Decreasing Adjacent Difference

You are given an array of integers nums.

easy

Check if Bitwise OR Has Trailing Zeros

You are given an array of positive integers nums.

medium

Maximum Number of Eaten Apples

There is a special kind of apple tree that grows apples every day for n days.

easy

Convert Date to Binary

You are given a string date representing a Gregorian calendar date in the yyyy-mm-dd format.

hard

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.

medium

Find Occurrences of an Element in an Array

You are given an integer array nums, an integer array queries, and an integer x.

medium

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.

medium

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.

easy

Check if Grid Satisfies Conditions

You are given a 2D matrix grid of size m x n.

medium

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.

hard

Find Maximum Non-decreasing Array Length

You are given a 0-indexed integer array nums.

medium

Count Substrings That Can Be Rearranged to Contain a String I

You are given two strings word1 and word2.

medium

Maximum Length of a Concatenated String with Unique Characters

You are given an array of strings arr.

medium

Length of the Longest Alphabetical Continuous Substring

An alphabetical continuous string is a string consisting of consecutive letters in the alphabet.

hard

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...

medium

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.

hard

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]...

medium

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.

hard

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.

easy

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.

medium

Sorting Three Groups

You are given an integer array nums.

hard

Subtree Inversion Sum

You are given an undirected tree rooted at node 0, with n nodes numbered from 0 to n - 1.

easy

Delete Characters to Make Fancy String

A fancy string is a string where no three consecutive characters are equal.

hard

Maximum Frequency of an Element After Performing Operations II

You are given an integer array nums and two integers k and numOperations.

medium

Triangle

Given a triangle array, return the minimum path sum from top to bottom.

medium

Course Schedule IV

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.

medium

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.

medium

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.

easy

Day of the Week

Given a date, return the corresponding day of the week for that date.

medium

The Time When the Network Becomes Idle

There is a network of n servers, labeled from 0 to n - 1.

medium

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].

medium

Ways to Express an Integer as Sum of Powers

Given two positive integers n and x.

hard

Reachable Nodes In Subdivided Graph

You are given an undirected graph (the "original graph") with n nodes labeled from 0 to n - 1.

medium

Jump Game

You are given an integer array nums.

medium

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.

hard

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.

medium

Longest Unequal Adjacent Groups Subsequence II

You are given a string array words, and an array groups, both arrays having length n.

hard

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.

easy

Harshad Number

An integer divisible by the sum of its digits is said to be a Harshad number.

medium

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.

hard

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.

medium

Minimum Area Rectangle

You are given an array of points in the X-Y plane points where points[i] = [xi, yi].

hard

Distinct Subsequences II

Given a string s, return the number of distinct non-empty subsequences of s.

medium

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.

medium

Number of Unique XOR Triplets II

You are given an integer array nums.

medium

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.

medium

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.

hard

Parallel Courses II

You are given an integer n, which indicates that there are n courses labeled from 1 to n.

hard

Match Substring After Replacement

You are given two strings s and sub.

medium

Time Needed to Rearrange a Binary String

You are given a binary string s.

medium

Replace Elements in an Array

You are given a 0-indexed array nums that consists of n distinct positive integers.

hard

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.

hard

Minimum Number of Operations to Make Array Continuous

You are given an integer array nums.

medium

Separate Squares I

You are given a 2D integer array squares.

medium

Maximum Strength of a Group

You are given a 0-indexed integer array nums representing the score of students in an exam.

hard

Falling Squares

There are several squares being dropped onto the X-axis of a 2D plane.

medium

Sum of Even Numbers After Queries

You are given an integer array nums and an array queries where queries[i] = [vali, indexi].

hard

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.

hard

Sudoku Solver

Write a program to solve a Sudoku puzzle by filling the empty cells.

hard

Longest Happy Prefix

A string is called a happy prefix if is a non-empty prefix which is also a suffix (excluding itself).

hard

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.

medium

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...

medium

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.

medium

Lexicographically Minimum String After Removing Stars

You are given a string s.

hard

Longest Palindrome After Substring Concatenation II

You are given two strings, s and t.

medium

Separate Black and White Balls

There are n balls on a table, each ball has a color black or white.

medium

Count Special Subsequences

You are given an array nums consisting of positive integers.

medium

Find a Safe Walk Through a Grid

You are given an m x n binary matrix grid and an integer health.

hard

Find Number of Ways to Reach the K-th Stair

You are given a non-negative integer k.

easy

Minimum Cost of Buying Candies With Discount

A shop is selling candies at a discount.

medium

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.

medium

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.

easy

Find the Longest Balanced Substring of a Binary String

You are given a binary string s consisting only of zeroes and ones.

medium

Maximum Split of Positive Even Integers

You are given an integer finalSum.

medium

Car Fleet

There are n cars at given miles away from the starting mile 0, traveling to reach the mile target.

medium

Most Profitable Path in a Tree

There is an undirected tree with n nodes labeled from 0 to n - 1, rooted at node 0.

medium

The k Strongest Values in an Array

Given an array of integers arr and an integer k.

medium

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.

hard

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...

medium

Count Paths With the Given XOR Value

You are given a 2D integer array grid with size m x n.

easy

Truncate Sentence

A sentence is a list of words that are separated by a single space with no leading or trailing spaces.

hard

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.

easy

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.

easy

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.

hard

Probability of a Two Boxes Having The Same Number of Distinct Balls

Given 2n balls of k distinct colors.

easy

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...

medium

Smallest Range II

You are given an integer array nums and an integer k.

hard

Minimum Cost for Cutting Cake II

There is an m x n cake that needs to be cut into 1 x 1 pieces.

medium

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.

hard

Maximum Number of K-Divisible Components

There is an undirected tree with n nodes labeled from 0 to n - 1.

medium

Minimum Operations to Reduce X to Zero

You are given an integer array nums and an integer x.

hard

Count K-Reducible Numbers Less Than N

You are given a binary string s representing a number n in its binary form.

medium

Reschedule Meetings for Maximum Free Time II

You are given an integer eventTime denoting the duration of an event.

easy

Duplicate Zeros

Given a fixed-length integer array arr, duplicate each occurrence of zero, shifting the remaining elements to the right.

medium

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.

medium

Minimum Number of Swaps to Make the String Balanced

You are given a 0-indexed string s of even length n.

easy

Count Hills and Valleys in an Array

You are given a 0-indexed integer array nums.

medium

Maximum Element After Decreasing and Rearranging

You are given an array of positive integers arr.

medium

Find the Maximum Number of Marked Indices

You are given a 0-indexed integer array nums.

medium

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.

medium

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.

medium

Count the Number of Beautiful Subarrays

You are given a 0-indexed integer array nums.

medium

Maximum Number of Operations to Move Ones to the End

You are given a binary string s.

hard

Minimum Replacements to Sort the Array

You are given a 0-indexed integer array nums.

medium

Unique Length-3 Palindromic Subsequences

Given a string s, return the number of unique palindromes of length three that are a subsequence of s.

medium

Alice and Bob Playing Flower Game

Alice and Bob are playing a turn-based game on a circular field surrounded by flowers.

medium

Unique Paths

There is a robot on an m x n grid.

medium

Minimum Number of Operations to Move All Balls to Each Box

You have n boxes.

medium

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.

medium

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.

hard

Count Paths That Can Form a Palindrome in a Tree

You are given a tree (i.e.

hard

Minimum Steps to Convert String with Operations

You are given two strings, word1 and word2, of equal length.

medium

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.

easy

Add Strings

Given two non-negative integers, num1 and num2 represented as string, return the sum of num1 and num2 as a string.

hard

Frequencies of Shortest Supersequences

You are given an array of strings words.

easy

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.

easy

Sort Array by Increasing Frequency

Given an array of integers nums, sort the array in increasing order based on the frequency of the values.

medium

Make Lexicographically Smallest Array by Swapping Elements

You are given a 0-indexed array of positive integers nums and a positive integer limit.

easy

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.

medium

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.

easy

Rings and Rods

There are n rings and each ring is either red, green, or blue.

easy

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...

medium

Minimum Length of Anagram Concatenation

You are given a string s, which is known to be a concatenation of anagrams of some string t.

medium

Maximum Number of Events That Can Be Attended

You are given an array of events where events[i] = [startDayi, endDayi].

easy

Decode XORed Array

There is a hidden integer array arr that consists of n non-negative integers.

medium

Longest Arithmetic Subsequence

Given an array nums of integers, return the length of the longest arithmetic subsequence in nums.

medium

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.

medium

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.

medium

Airplane Seat Assignment Probability

n passengers board an airplane with exactly n seats.

medium

Maximum Consecutive Floors Without Special Floors

Alice manages a company and has rented some floors of a building as office space.

medium

Minimum Total Space Wasted With K Resizing Operations

You are currently designing a dynamic array.

medium

Minimum Operations to Exceed Threshold Value II

You are given a 0-indexed integer array nums, and an integer k.

hard

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).

medium

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.

medium

Destroy Sequential Targets

You are given a 0-indexed array nums consisting of positive integers, representing targets on a number line.

medium

Corporate Flight Bookings

There are n flights that are labeled from 1 to n.

hard

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.

medium

Minimum Operations to Make a Uni-Value Grid

You are given a 2D integer grid of size m x n and an integer x.

medium

Count Unhappy Friends

You are given a list of preferences for n friends, where n is always even.

easy

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.

medium

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.

medium

Maximum Prime Difference

You are given an integer array nums.

hard

Minimum Number of Refueling Stops

A car travels from a starting position to a destination which is target miles east of the starting position.

medium

Find the Length of the Longest Common Prefix

You are given two arrays with positive integers arr1 and arr2.

medium

Elimination Game

You have a list arr of all integers in the range [1, n] sorted in a strictly increasing order.

easy

Sum of Digits of String After Convert

You are given a string s consisting of lowercase English letters, and an integer k.

hard

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.

hard

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].

easy

Merge Two 2D Arrays by Summing Values

You are given two 2D integer arrays nums1 and nums2.

hard

Maximum Deletions on a String

You are given a string s consisting of only lowercase English letters.

easy

Reverse Degree of a String

Given a string s, calculate its reverse degree.

medium

Memoize

Given a function fn, return a memoized version of that function.

hard

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.

medium

Maximum Distance in Arrays

You are given m arrays, where each array is sorted in ascending order.

medium

Video Stitching

You are given a series of video clips from a sporting event that lasted time seconds.

medium

Maximum Number of Removable Characters

You are given two strings s and p where p is a subsequence of s.

hard

Super Washing Machines

You have n super washing machines on a line.

easy

Find the Maximum Divisibility Score

You are given two integer arrays nums and divisors.

easy

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.

easy

Find the Encrypted String

You are given a string s and an integer k.

hard

Count Connected Components in LCM Graph

You are given an array of integers nums of size n and a positive integer threshold.

easy

Coupon Code Validator

You are given three arrays of length n that describe the properties of n coupons: code, businessLine, and isActive.

easy

Find the Highest Altitude

There is a biker going on a road trip.

medium

Rotate Function

You are given an integer array nums of length n.

easy

Minimum Absolute Difference

Given an array of distinct integers arr, find all pairs of elements with the minimum absolute difference of any two elements.

hard

Number of Beautiful Integers in the Range

You are given positive integers low, high, and k.

easy

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.

hard

Sum of Good Subsequences

You are given an integer array nums.

medium

Single Number III

Given an integer array nums, in which exactly two elements appear only once and all the other elements appear exactly twice.

medium

Frequency of the Most Frequent Element

The frequency of an element is the number of times it occurs in an array.

medium

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.

medium

Fair Distribution of Cookies

You are given an integer array cookies, where cookies[i] denotes the number of cookies in the ith bag.

medium

Append Characters to String to Make Subsequence

You are given two strings s and t consisting of only lowercase English letters.

easy

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.

medium

Fruit Into Baskets

You are visiting a farm that has a single row of fruit trees arranged from left to right.

medium

Longest Palindrome After Substring Concatenation I

You are given two strings, s and t.

hard

Minimum Number of Operations to Make String Sorted

You are given a string s (0-indexed)​​​​​​.

easy

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.

easy

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.

medium

Task Scheduler

You are given an array of CPU tasks, each labeled with a letter from A to Z, and a number n.

hard

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 ')'.

hard

Longest Chunked Palindrome Decomposition

You are given a string text.

medium

First Day Where You Have Been in All the Rooms

There are n rooms you need to visit, labeled from 0 to n - 1.

medium

Stone Game

Alice and Bob play a game with piles of stones.

easy

Cells with Odd Values in a Matrix

There is an m x n matrix that is initialized to all 0's.

medium

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.

hard

Count Palindromic Subsequences

Given a string of digits s, return the number of palindromic subsequences of s having length 5.

medium

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.

medium

Maximum OR

You are given a 0-indexed integer array nums of length n and an integer k.

medium

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.

medium

Largest Combination With Bitwise AND Greater Than Zero

The bitwise AND of an array nums is the bitwise AND of all integers in nums.

hard

Replace Non-Coprime Numbers in Array

You are given an array of integers nums.

medium

Rectangle Area

Given the coordinates of two rectilinear rectangles in a 2D plane, return the total area covered by the two rectangles.

medium

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.

easy

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.

medium

Minimum Non-Zero Product of the Array Elements

You are given a positive integer p.

medium

Number of Zero-Filled Subarrays

Given an integer array nums, return the number of subarrays filled with 0.

easy

Find Maximum Number of String Pairs

You are given a 0-indexed array words consisting of distinct strings.

easy

Calculate Money in a Piggy Bank

Hercy wants to save money for his first car.

medium

Four Divisors

Given an integer array nums, return the sum of divisors of the integers in that array that have exactly four divisors.

medium

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,...

medium

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.

medium

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.

medium

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.

medium

Maximize Total Cost of Alternating Subarrays

You are given an integer array nums with length n.

medium

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,...

easy

Merge Strings Alternately

You are given two strings word1 and word2.

hard

Number of Possible Sets of Closing Branches

There is a company with n branches across the country, some of which are connected by roads.

medium

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.

easy

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.

hard

Transform to Chessboard

You are given an n x n binary grid board.

medium

Minimum Increment Operations to Make Array Beautiful

You are given a 0-indexed integer array nums having length n, and an integer k.

medium

Largest Number

Given a list of non-negative integers nums, arrange them such that they form the largest number and return it.

medium

Minimum Length of String After Deleting Similar Ends

Given a string s consisting only of characters 'a', 'b', and 'c'.

easy

Add Digits

Given an integer num, repeatedly add all its digits until the result has only one digit, and return it.

medium

Minimum Time to Repair Cars

You are given an integer array ranks representing the ranks of some mechanics.

medium

Maximum and Minimum Sums of at Most Size K Subsequences

You are given an integer array nums and a positive integer k.

medium

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.

medium

String Compression III

Given a string word, compress it using the following algorithm: Return the string comp.

hard

Apply Operations to Maximize Frequency Score

You are given a 0-indexed integer array nums and an integer k.

hard

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.

hard

Max Dot Product of Two Subsequences

Given two arrays nums1 and nums2.

hard

Maximum Performance of a Team

You are given two integers n and k and two integer arrays speed and efficiency both of length n.

hard

Maximum Number of Achievable Transfer Requests

We have n buildings numbered from 0 to n - 1.

hard

Minimum Operations to Make Array Equal to Target

You are given two positive integer arrays nums and target, of the same length.

hard

Length of the Longest Valid Substring

You are given a string word and an array of strings forbidden.

easy

Minimum Operations to Make the Array Increasing

You are given an integer array nums (0-indexed).

medium

Minimum Array Length After Pair Removals

Given an integer array num sorted in non-decreasing order.

medium

Minimum Falling Path Sum

Given an n x n array of integers matrix, return the minimum sum of any falling path through matrix.

easy

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.

hard

Dice Roll Simulation

A die simulator generates a random number from 1 to 6 for each roll.

easy

Minimum Changes To Make Alternating Binary String

You are given a string s consisting only of the characters '0' and '1'.

medium

Filter Restaurants by Vegan-Friendly, Price and Distance

Given the array restaurants where restaurants[i] = [idi, ratingi, veganFriendlyi, pricei, distancei].

medium

Find the Maximum Factor Score of Array

You are given an integer array nums.

medium

Generate Binary Strings Without Adjacent Zeros

You are given a positive integer n.

hard

Profitable Schemes

There is a group of n members, and a list of various crimes they could commit.

hard

Find All People With Secret

You are given an integer n indicating there are n people numbered from 0 to n - 1.

medium

Minimum Score by Changing Two Elements

You are given an integer array nums.

medium

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 <...

easy

Find X-Sum of All K-Long Subarrays I

You are given an array nums of n integers and two integers k and x.

medium

Reduce Array Size to The Half

You are given an integer array arr.

medium

Minimize Hamming Distance After Swap Operations

You are given two integer arrays, source and target, both of length n.

medium

Finding the Users Active Minutes

You are given the logs for users' actions on a platform, and an integer k.

medium

Promise Time Limit

Given an asynchronous function fn and a time t in milliseconds, return a new time limited version of the input function.

medium

Minimize the Maximum of Two Arrays

We have two arrays arr1 and arr2 which are initially empty.

hard

Special Binary String

Special binary strings are binary strings with the following two properties: You are given a special binary string s.

easy

Sort Integers by The Number of 1 Bits

You are given an integer array arr.

hard

Subsequence With the Minimum Score

You are given two strings s and t.

medium

Prime Palindrome

Given an integer n, return the smallest prime palindrome greater than or equal to n.

medium

Maximum Score From Removing Stones

You are playing a solitaire game with three piles of stones of sizes a​​​​​​, b,​​​​​​ and c​​​​​​ respectively.

hard

Smallest Substring With Identical Characters I

You are given a binary string s of length n and an integer numOps.

hard

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.

medium

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.

medium

Restore the Array From Adjacent Pairs

There is an integer array nums that consists of n unique elements, but you have forgotten it.

medium

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.

medium

Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent elements.

hard

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.

easy

Difference Between Element Sum and Digit Sum of an Array

You are given a positive integer array nums.

medium

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).

hard

Perfect Rectangle

Given an array rectangles where rectangles[i] = [xi, yi, ai, bi] represents an axis-aligned rectangle.

easy

Delete Greatest Value in Each Row

You are given an m x n matrix grid consisting of positive integers.

easy

Maximum Product of Three Numbers

Given an integer array nums, find three numbers whose product is maximum and return the maximum product.

hard

Minimize the Maximum Adjacent Element Difference

You are given an array of integers nums.

easy

Earliest Finish Time for Land and Water Rides I

You are given two categories of theme park attractions: land rides and water rides.

medium

Binary Trees With Factors

Given an array of unique integers, arr, where each integer arr[i] is strictly greater than 1.

medium

Smallest Palindromic Rearrangement I

You are given a palindromic string s.

medium

Kth Largest Element in an Array

Given an integer array nums and an integer k, return the kth largest element in the array.

medium

Remove Methods From Project

You are maintaining a project that has n methods numbered from 0 to n - 1.

medium

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.

medium

Minimum Number of Steps to Make Two Strings Anagram

You are given two strings of the same length s and t.

easy

Kids With the Greatest Number of Candies

There are n kids with candies.

medium

Divide Two Integers

Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator.

easy

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.

easy

Sum Each Row of a Grid

Practice 2D array basics: nested iteration and row/column indexing.

medium

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.

medium

Letter Case Permutation

Given a string s, you can transform every letter individually to be lowercase or uppercase to create another string.

medium

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.

medium

Grumpy Bookstore Owner

There is a bookstore owner that has a store open for n minutes.

hard

Lexicographically Smallest Generated String

You are given two strings, str1 and str2, of lengths n and m, respectively.

medium

Sum Game

Alice and Bob take turns playing a game, with Alice starting first.

easy

Isomorphic Strings

Given two strings s and t, determine if they are isomorphic.

hard

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.

medium

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.

easy

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).

medium

Cheapest Flights Within K Stops

There are n cities connected by some number of flights.

medium

Reduction Operations to Make the Array Elements Equal

Given an integer array nums, your goal is to make all elements in nums equal.

medium

Minimum Number of Flips to Make the Binary String Alternating

You are given a binary string s.

medium

Visit Array Positions to Maximize Score

You are given a 0-indexed integer array nums and a positive integer x.

hard

Create Components With Same Value

There is an undirected tree with n nodes labeled from 0 to n - 1.

easy

Excel Sheet Column Number

Given a string columnTitle that represents the column title as appears in an Excel sheet, return its corresponding column number.

medium

Maximum Possible Number by Binary Concatenation

You are given an array of integers nums of size 3.

easy

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.

medium

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.

medium

Repeated DNA Sequences

The DNA sequence is composed of a series of nucleotides abbreviated as 'A', 'C', 'G', and 'T'.

easy

Snake in Matrix

There is a snake in an n x n matrix grid and can move in four possible directions.

easy

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.

medium

Score of Parentheses

Given a balanced parentheses string s, return the score of the string.

medium

Equal Sum Arrays With Minimum Number of Operations

You are given two arrays of integers nums1 and nums2, possibly of different lengths.

hard

Maximize Subarray Sum After Removing All Occurrences of One Element

You are given an integer array nums.

easy

Make Three Strings Equal

You are given three strings: s1, s2, and s3.

medium

Find the Minimum Amount of Time to Brew Potions

You are given two integer arrays, skill and mana, of length n and m, respectively.

medium

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.

hard

Count Number of Balanced Permutations

You are given a string num.

medium

Number of Laser Beams in a Bank

Anti-theft security devices are activated inside a bank.

medium

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.

medium

Special Permutations

You are given a 0-indexed integer array nums containing n distinct positive integers.

medium

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.

medium

Continuous Subarray Sum

Given an integer array nums and an integer k, return true if nums has a good subarray or false otherwise.

medium

Sum of Square Numbers

Given a non-negative integer c, decide whether there're two integers a and b such that a2 + b2 = c.

easy

Count Prefix and Suffix Pairs I

You are given a 0-indexed string array words.

hard

Cut Off Trees for Golf Event

You are asked to cut off all the trees in a forest for a golf event.

easy

Number of Unequal Triplets in Array

You are given a 0-indexed array of positive integers nums.

medium

Display Table of Food Orders in a Restaurant

Given the array orders, which represents the orders that customers have done in a restaurant.

medium

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...

medium

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.

medium

Maximum Total Damage With Spell Casting

A magician has various spells.

easy

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.

hard

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.

easy

Special Array With X Elements Greater Than or Equal X

You are given an array nums of non-negative integers.

medium

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.

medium

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.

medium

House Robber II

You are a professional robber planning to rob houses along a street.

medium

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.

medium

Longest Nice Subarray

You are given an array nums consisting of positive integers.

easy

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.

easy

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.

medium

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.

easy

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.

medium

Maximize Area of Square Hole in Grid

You are given the two integers, n and m and two integer arrays, hBars and vBars.

easy

Count Asterisks

You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair.

hard

Minimum Number of Visited Cells in a Grid

You are given a 0-indexed m x n integer matrix grid.

medium

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.

easy

XOR Operation in an Array

You are given an integer n and an integer start.

medium

Queens That Can Attack the King

On a 0-indexed 8 x 8 chessboard, there can be multiple black queens and one white king.

medium

Find the Winner of an Array Game

Given an integer array arr of distinct integers and an integer k.

easy

Check if Number Has Equal Digit Count and Digit Value

You are given a 0-indexed string num of length n consisting of digits.

hard

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...

medium

Longest Turbulent Subarray

Given an integer array arr, return the length of a maximum size turbulent subarray of arr.

medium

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.

hard

Minimum Number of Increments on Subarrays to Form a Target Array

You are given an integer array target.

medium

Minimum Division Operations to Make Array Non Decreasing

You are given an integer array nums.

hard

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...

hard

Reducing Dishes

A chef has collected data on the satisfaction level of his n dishes.

medium

Smallest Missing Non-negative Integer After Operations

You are given a 0-indexed integer array nums and an integer value.

medium

Minimum Moves to Reach Target Score

You are playing a game with integers.

easy

Longest Alternating Subarray

You are given a 0-indexed integer array nums.

easy

Find the Child Who Has the Ball After K Seconds

You are given two positive integers n and k.

medium

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.

hard

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.

medium

Add Minimum Number of Rungs

You are given a strictly increasing integer array rungs that represents the height of rungs on a ladder.

hard

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...

medium

Pancake Sorting

Given an array of integers arr, sort the array by performing a series of pancake flips.

medium

Properties Graph

You are given a 2D integer array properties having dimensions n x m and an integer k.

hard

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.

hard

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.

hard

Minimum Cost to Equalize Array

You are given an integer array nums and two integers cost1 and cost2.

medium

Eliminate Maximum Number of Monsters

You are playing a video game where you are defending your city from a group of n monsters.

medium

Minimum Time to Make Rope Colorful

Alice has n balloons arranged on a rope.

medium

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.

easy

Remove Letter To Equalize Frequency

You are given a 0-indexed string word, consisting of lowercase English letters.

medium

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...

hard

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.

easy

Final Array State After K Multiplication Operations I

You are given an integer array nums, an integer k, and an integer multiplier.

medium

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.

medium

K Radius Subarray Averages

You are given a 0-indexed array nums of n integers, and an integer k.

easy

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.

hard

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].

hard

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].

medium

Where Will the Ball Fall

You have a 2-D grid of size m x n representing a box, and you have n balls.

hard

Recover the Original Array

Alice had a 0-indexed array arr consisting of n positive integers.

easy

First Unique Character in a String

Given a string s, find the first non-repeating character in it and return its index.

medium

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...

medium

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.

hard

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.

hard

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.

medium

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.

medium

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.

medium

Subsets

Given an integer array nums of unique elements, return all possible subsets (the power set).

medium

K-Concatenation Maximum Sum

Given an integer array arr and an integer k, modify the array by repeating it k times.

medium

Longest String Chain

You are given an array of words where each word consists of lowercase English letters.

hard

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.

easy

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.

medium

Count Collisions on a Road

There are n cars on an infinitely long road.

medium

Smallest Value After Replacing With Sum of Prime Factors

You are given a positive integer n.

hard

Stickers to Spell Word

We are given n different types of stickers.

easy

Take Gifts From the Richest Pile

You are given an integer array gifts denoting the number of gifts in various piles.

easy

Power of Four

Given an integer n, return true if it is a power of four.

medium

Count Number of Bad Pairs

You are given a 0-indexed integer array nums.

medium

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:...

easy

Largest Local Values in a Matrix

You are given an n x n integer matrix grid.

hard

Check if Point Is Reachable

There exists an infinitely large grid.

easy

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.

easy

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.

hard

Palindrome Partitioning II

Given a string s, partition s such that every substring of the partition is a palindrome.

medium

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...

easy

Assign Cookies

Assume you are an awesome parent and want to give your children some cookies.

medium

Reachable Nodes With Restrictions

There is an undirected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.

hard

String Transformation

You are given two strings s and t of equal length n.

medium

Making File Names Unique

Given an array of strings names of size n.

medium

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.

easy

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.

medium

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.

medium

Find if Array Can Be Sorted

You are given a 0-indexed array of positive integers nums.

medium

Longest Palindromic Subsequence

Given a string s, find the longest palindromic subsequence's length in s.

easy

Count Vowel Substrings of a String

A substring is a contiguous (non-empty) sequence of characters within a string.

hard

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.

medium

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.

medium

Maximum Balanced Shipments

You are given an integer array weight of length n, representing the weights of n parcels arranged in a straight line.

medium

Minimum Limit of Balls in a Bag

You are given an integer array nums where the ith bag contains nums[i] balls.

medium

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].

hard

Maximize Value of Function in a Ball Passing Game

You are given an integer array receiver of length n and an integer k.

medium

Ways to Make a Fair Array

You are given an integer array nums.

hard

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.

medium

Decode String

Given an encoded string, return its decoded string.

medium

Rotate Image

You are given an n x n 2D matrix representing an image, rotate the image by 90 degrees (clockwise).

hard

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.

easy

Maximum Strong Pair XOR I

You are given a 0-indexed integer array nums.

easy

Check if All Characters Have Equal Number of Occurrences

Given a string s, return true if s is a good string, or false otherwise.

medium

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.

medium

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.

medium

Count Number of Nice Subarrays

Given an array of integers nums and an integer k.

easy

Reformat The String

You are given an alphanumeric string s.

hard

Minimum Operations to Make Elements Within K Subarrays Equal

You are given an integer array nums and two integers, x and k.

medium

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].

hard

Count of Integers

You are given two numeric strings num1 and num2 and two integers max_sum and min_sum.

medium

Reveal Cards In Increasing Order

You are given an integer array deck.

easy

Convert a Number to Hexadecimal

Given a 32-bit integer num, return a string representing its hexadecimal representation.

hard

Maximize Consecutive Elements in an Array After Modification

You are given a 0-indexed array nums consisting of positive integers.

medium

Incremental Memory Leak

You are given two integers memory1 and memory2 representing the available memory in bits on two memory sticks.

easy

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.

medium

Count the Number of Substrings With Dominant Ones

You are given a binary string s.

medium

Maximum Product of First and Last Elements of a Subsequence

You are given an integer array nums and an integer m.

easy

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.

easy

Destination City

You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi.

medium

Solving Questions With Brainpower

You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri].

medium

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.

hard

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).

medium

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.

hard

Shortest Matching Substring

You are given a string s and a pattern string p, where p contains exactly two '*' characters.

hard

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.

easy

Calculate Digit Sum of a String

You are given a string s consisting of digits and an integer k.

hard

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.

easy

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).

medium

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...

easy

Count Substrings That Satisfy K-Constraint I

You are given a binary string s and an integer k.

medium

Ways to Split Array Into Good Subarrays

You are given a binary array nums.

hard

Peaks in Array

A peak in an array arr is an element that is greater than its previous and next element in arr.

easy

Intersection of Two Arrays II

Given two integer arrays nums1 and nums2, return an array of their intersection.

medium

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.

medium

Group the People Given the Group Size They Belong To

There are n people that are split into some unknown number of groups.

easy

Sum of Values at Indices With K Set Bits

You are given a 0-indexed integer array nums and an integer k.

hard

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].

medium

Letter Tile Possibilities

You have n tiles, where each tile has one letter tiles[i] printed on it.

easy

Running Sum of 1d Array

Given an array nums.

medium

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.

hard

Maximum Number of Darts Inside of a Circular Dartboard

Alice is throwing n darts on a very large wall.

easy

Defanging an IP Address

Given a valid (IPv4) IP address, return a defanged version of that IP address.

medium

Super Ugly Number

A super ugly number is a positive integer whose prime factors are in the array primes.

medium

Find Minimum Time to Reach Last Room II

There is a dungeon with n x m rooms arranged as a grid.

easy

Count Pairs Of Similar Strings

You are given a 0-indexed string array words.

hard

Get the Maximum Score

You are given two sorted arrays of distinct integers nums1 and nums2.

medium

Decoded String at Index

You are given an encoded string s.

medium

Count Number of Homogenous Substrings

Given a string s, return the number of homogenous substrings of s.

medium

Container With Most Water

You are given an integer array height of length n.

hard

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.

easy

Type of Triangle

You are given a 0-indexed integer array nums of size 3 which can form the sides of a triangle.

easy

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.

medium

Can I Win

In the "100 game" two players take turns adding, to a running total, any integer from 1 to 10.

medium

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.

easy

Long Pressed Name

Your friend is typing his name into a keyboard.

medium

Number of Sub-arrays With Odd Sum

Given an array of integers arr, return the number of subarrays with an odd sum.

hard

Apply Operations to Maximize Score

You are given an array nums of n positive integers and an integer k.

medium

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.

medium

Average Waiting Time

There is a restaurant with a single chef.

easy

Find Valid Pair of Adjacent Digits in String

You are given a string s consisting only of digits.

easy

Max Pair Sum in an Array

You are given an integer array nums.

medium

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).

easy

Count Odd Numbers in an Interval Range

Given two non-negative integers low and high.

medium

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...

medium

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.

hard

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)...

easy

Set Mismatch

You have a set of integers s, which originally contains all the numbers from 1 to n.

medium

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.

medium

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.

medium

Sentence Similarity III

You are given two strings sentence1 and sentence2, each representing a sentence composed of words.

medium

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.

medium

Total Hamming Distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

easy

Distance Between Bus Stops

A bus has n stops numbered from 0 to n - 1 that form a circle.

hard

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.

medium

Minimum Operations to Make Binary Array Elements Equal to One II

You are given a binary array nums.

hard

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 <=...

easy

Shortest Completing Word

Given a string licensePlate and an array of strings words, find the shortest completing word in words.

hard

Maximum AND Sum of Array

You are given an integer array nums of length n and an integer numSlots such that 2 * numSlots >= n.

medium

Restore IP Addresses

A valid IP address consists of exactly four integers separated by single dots.

hard

Minimum Cost Walk in Weighted Graph

There is an undirected weighted graph with n vertices labeled from 0 to n - 1.

medium

Longest Repeating Character Replacement

You are given a string s and an integer k.

easy

Linked List Cycle Detection

Determine whether a singly-linked list loops back on itself instead of ending in null.

medium

Binary Tree Left Side View

Return the value of the leftmost node visible at each level of a binary tree, from top to bottom.

easy

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.

easy

Find Target Indices After Sorting Array

You are given a 0-indexed integer array nums and a target element target.

easy

Kth Distinct String in an Array

A distinct string is a string that is present only once in an array.

medium

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.

hard

Put Marbles in Bags

You have k bags.

easy

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.

medium

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.

medium

Sum of Two Integers

Given two integers a and b, return the sum of the two integers without using the operators + and -.

hard

Distinct Subsequences

Given two strings s and t, return the number of distinct subsequences of s which equals t.

medium

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 ' '.

hard

Minimum Difference in Sums After Removal of Elements

You are given a 0-indexed integer array nums consisting of 3 * n elements.

medium

XOR Queries of a Subarray

You are given an array arr of positive integers.

easy

Summary Ranges

You are given a sorted unique integer array nums.

medium

Maximal Score After Applying K Operations

You are given a 0-indexed integer array nums and an integer k.

easy

Split the Array

You are given an integer array nums of even length.

hard

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.

medium

Ugly Number III

An ugly number is a positive integer that is divisible by a, b, or c.

medium

Sort Matrix by Diagonals

You are given an n x n square matrix of integers grid.

easy

Find Words That Can Be Formed by Characters

You are given an array of strings words and a string chars.

medium

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.

easy

Longest Uncommon Subsequence I

Given two strings a and b, return the length of the longest uncommon subsequence between a and b.

hard

Maximum Number of Moves to Kill All Pawns

There is a 50 x 50 chessboard with one knight and some pawns on it.

medium

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"...

medium

Maximum Score From Removing Substrings

You are given a string s and two integers x and y.

medium

Number of Nodes in the Sub-Tree With the Same Label

You are given a tree (i.e.

medium

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.

easy

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.

medium

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.

easy

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.

medium

Count Submatrices With All Ones

Given an m x n binary matrix mat, return the number of submatrices that have all ones.

medium

Find All Possible Stable Binary Arrays I

You are given 3 positive integers zero, one, and limit.

medium

Soup Servings

You have two soups, A and B, each starting with n mL.

medium

Maximize Win From Two Segments

There are some prizes on the X-axis.

medium

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.

easy

Third Maximum Number

Given an integer array nums, return the third distinct maximum number in this array.

medium

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.

medium

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.

medium

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.

medium

Get Equal Substrings Within Budget

You are given two strings s and t of the same length and an integer maxCost.

hard

Design Cancellable Function

Sometimes you have a long running task, and you may wish to cancel it before it completes.

hard

Minimum Difficulty of a Job Schedule

You want to schedule a list of jobs in d days.

easy

Divide an Array Into Subarrays With Minimum Cost I

You are given an array of integers nums of length n.

hard

Find X-Sum of All K-Long Subarrays II

You are given an array nums of n integers and two integers k and x.

easy

Minimum Index Sum of Two Lists

Given two arrays of strings list1 and list2, find the common strings with the least index sum.

medium

Minimum Array Sum

You are given an integer array nums and three integers k, op1, and op2.

medium

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.

easy

Keep Multiplying Found Values by Two

You are given an array of integers nums.

medium

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.

medium

Count Submatrices with Top-Left Element and Sum Less Than k

You are given a 0-indexed integer matrix grid and an integer k.

hard

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.

easy

Sum of Squares of Special Elements

You are given a 1-indexed integer array nums of length n.

medium

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.

medium

Maximum Coins From K Consecutive Bags

There are an infinite amount of bags on a number line, one bag for each coordinate.

medium

Check if There is a Valid Partition For The Array

You are given a 0-indexed integer array nums.

medium

Minimize the Maximum Difference of Pairs

You are given a 0-indexed integer array nums and an integer p.

medium

Majority Element II

Given an integer array of size n, find all elements that appear more than ⌊ n/3 ⌋ times.

easy

Minimum Cost to Move Chips to The Same Position

We have n chips, where the position of the ith chip is position[i].

easy

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 "?".

medium

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.

easy

Check Balanced String

You are given a string num consisting of only digits.

medium

Largest Values From Labels

You are given n item's value and label as two integer arrays values and labels.

easy

Find Subarrays With Equal Sum

Given a 0-indexed integer array nums, determine whether there exist two subarrays of length 2 with equal sum.

medium

Shortest and Lexicographically Smallest Beautiful String

You are given a binary string s and a positive integer k.

hard

Number of Unique Good Subsequences

You are given a binary string binary.

medium

Minimize Maximum of Array

You are given a 0-indexed array nums comprising of n non-negative integers.

medium

Make Number of Distinct Characters Equal

You are given two 0-indexed strings word1 and word2.

hard

Remove Boxes

You are given several boxes with different colors represented by different positive numbers.

hard

Build a Matrix With Conditions

You are given a positive integer k.

medium

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.

medium

Double Modular Exponentiation

You are given a 0-indexed 2D array variables where variables[i] = [ai, bi, ci, mi], and an integer target.

easy

Maximum Average Subarray I

You are given an integer array nums consisting of n elements, and an integer k.

hard

Maximum Sum of Edge Values in a Graph

You are given an undirected connected graph of n nodes, numbered from 0 to n - 1.

medium

Watering Plants

You want to water n plants in your garden with a watering can.

easy

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.

easy

Apply Operations to an Array

You are given a 0-indexed array nums of size n consisting of non-negative integers.

hard

Find the Median of the Uniqueness Array

You are given an integer array nums.

easy

Remove All Adjacent Duplicates In String

You are given a string s consisting of lowercase English letters.

medium

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.

medium

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.

hard

Subarray With Elements Greater Than Varying Threshold

You are given an integer array nums and an integer threshold.

medium

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.

medium

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...

hard

Longest Substring of One Repeating Character

You are given a 0-indexed string s.

hard

Number of Beautiful Partitions

You are given a string s that consists of the digits '1' to '9' and two integers k and minLength.

easy

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.

medium

Uncrossed Lines

You are given two integer arrays nums1 and nums2.

medium

Sliding Subarray Beauty

Given an integer array nums containing n integers, find the beauty of each subarray of size k.

easy

Determine Color of a Chessboard Square

You are given coordinates, a string that represents the coordinates of a square of the chessboard.

hard

Count All Possible Routes

You are given an array of distinct positive integers locations where locations[i] represents the position of city i.

easy

Substrings of Size Three with Distinct Characters

A string is good if there are no repeated characters.

hard

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.

medium

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...

easy

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.

medium

Minimum Operations to Maximize Last Elements in Arrays

You are given two 0-indexed integer arrays, nums1 and nums2, both having length n.

easy

Minimum Cost to Reach Every Position

You are given an integer array cost of size n.

easy

Semi-Ordered Permutation

You are given a 0-indexed permutation of n integers nums.

easy

Check if Any Element Has Prime Frequency

You are given an integer array nums.

hard

Find the Shortest Superstring

Given an array of strings words, return the smallest string that contains each string in words as a substring.

easy

Teemo Attacking

Our hero Teemo is attacking an enemy Ashe with poison attacks!

medium

Count Artifacts That Can Be Extracted

There is an n x n 0-indexed grid with some artifacts buried in it.

hard

Minimum Operations to Make Character Frequencies Equal

You are given a string s.

easy

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.

medium

Minimum Number of Flips to Make Binary Grid Palindromic II

You are given an m x n binary matrix grid.

easy

Find the Losers of the Circular Game

There are n friends that are playing a game.

hard

Subarrays with K Different Integers

Given an integer array nums and an integer k, return the number of good subarrays of nums.

medium

Minimum Seconds to Equalize a Circular Array

You are given a 0-indexed array nums containing n integers.

hard

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.

hard

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.

medium

Most Frequent Prime

You are given a m x n 0-indexed 2D matrix mat.

hard

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).

hard

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.

medium

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.

medium

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.

hard

Maximum Elegance of a K-Length Subsequence

You are given a 0-indexed 2D integer array items of length n and an integer k.

hard

Delete Duplicate Folders in System

Due to a bug, there are many duplicate folders in a file system.

medium

Masking Personal Information

You are given a personal information string s, representing either an email address or a phone number.

easy

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.

hard

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.

medium

Apply Bitwise Operations to Make Strings Equal

You are given two 0-indexed binary strings s and target of the same length n.

hard

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.

hard

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.

medium

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.

medium

Jump Game II

You are given a 0-indexed array of integers nums of length n.

hard

Find the Count of Good Integers

You are given two positive integers n and k.

medium

Remove Adjacent Almost-Equal Characters

You are given a 0-indexed string word.

medium

Last Moment Before All Ants Fall Out of a Plank

We have a wooden plank of the length n units.

medium

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.

medium

Find Xor-Beauty of Array

You are given a 0-indexed integer array nums.

easy

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.

hard

Largest Component Size by Common Factor

You are given an integer array of unique positive integers nums.

easy

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.

medium

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).

medium

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 i​​​​​​th​​​​ task...

easy

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).

medium

Coloring A Border

You are given an m x n integer matrix grid, and three integers row, col, and color.

hard

Number of Valid Move Combinations On Chessboard

There is an 8 x 8 chessboard containing n pieces (rooks, queens, or bishops).

medium

Best Team With No Conflicts

You are the manager of a basketball team.

medium

Find the Value of the Partition

You are given a positive integer array nums.

hard

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).

hard

Maximum Height by Stacking Cuboids

Given n cuboids where the dimensions of the ith cuboid is cuboids[i] = [widthi, lengthi, heighti] (0-indexed).

medium

Longest Palindromic Subsequence After at Most K Operations

You are given a string s and an integer k.

medium

Find X Value of Array I

You are given an array of positive integers nums, and a positive integer k.

easy

Find the Maximum Achievable Number

Given two integers, num and t.

medium

Path With Minimum Effort

You are a hiker preparing for an upcoming hike.

medium

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...

medium

Move Pieces to Obtain a String

You are given two strings start and target, both of length n.

hard

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.

medium

Minimum Operations to Make a Special Number

You are given a 0-indexed string num representing a non-negative integer.

hard

Minimum Cost to Split an Array

You are given an integer array nums and an integer k.

medium

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.

medium

Filling Bookcase Shelves

You are given an array books where books[i] = [thicknessi, heighti] indicates the thickness and height of the ith book.

medium

Max Area of Island

You are given an m x n binary matrix grid.

hard

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.

medium

Additive Number

An additive number is a string whose digits can form an additive sequence.

medium

K-th Symbol in Grammar

We build a table of n rows (1-indexed).

medium

Partition Labels

You are given a string s.

easy

Reverse Vowels of a String

Given a string s, reverse only all the vowels in the string and return it.

medium

Maximum Number That Sum of the Prices Is Less Than or Equal to K

You are given an integer k and an integer x.

medium

Wiggle Sort II

Given an integer array nums, reorder it such that nums[0] < nums[1] > nums[2] < nums[3]....

hard

Time Taken to Mark All Nodes

There exists an undirected tree with n nodes numbered 0 to n - 1.

hard

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].

hard

Number of Ways to Earn Points

There is a test that has n types of questions.

easy

Most Frequent Even Element

Given an integer array nums, return the most frequent even element.

easy

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.

hard

Reverse Pairs

Given an integer array nums, return the number of reverse pairs in the array.

medium

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.

easy

Fizz Buzz

Given an integer n, return a string array answer (1-indexed) where:

medium

Substring XOR Queries

You are given a binary string s, and a 2D integer array queries where queries[i] = [firsti, secondi].

hard

Number of Great Partitions

You are given an array nums consisting of positive integers and an integer k.

medium

Search in Rotated Sorted Array

There is an integer array nums sorted in ascending order (with distinct values).

hard

Numbers At Most N Given Digit Set

Given an array of digits which is sorted in non-decreasing order.

easy

Rank Transform of an Array

Given an array of integers arr, replace each element with its rank.

medium

Count Beautiful Splits in an Array

You are given an array nums.

hard

Process Restricted Friend Requests

You are given an integer n indicating the number of people in a network.

medium

Make String a Subsequence Using Cyclic Increments

You are given two 0-indexed strings str1 and str2.

hard

Earliest Possible Day of Full Bloom

You have n flower seeds.

hard

Minimum Number of K Consecutive Bit Flips

You are given a binary array nums and an integer k.

hard

Concatenated Words

Given an array of strings words (without duplicates), return all the concatenated words in the given list of words.

medium

Find and Replace Pattern

Given a list of strings words and a string pattern, return a list of words[i] that match pattern.

easy

Minimum Moves to Convert String

You are given a string s consisting of n characters which are either 'X' or 'O'.

medium

Minimum Cost for Cutting Cake I

There is an m x n cake that needs to be cut into 1 x 1 pieces.

hard

Minimum Operations to Make Array Elements Zero

You are given a 2D array queries, where queries[i] is of the form [l, r].

medium

Minimum Removals to Balance Array

You are given an integer array nums and an integer k.

medium

Equal Sum Grid Partition I

You are given an m x n matrix grid of positive integers.

hard

Sum of Total Strength of Wizards

As the ruler of a kingdom, you have an army of wizards at your command.

hard

Maximize Number of Nice Divisors

You are given a positive integer primeFactors.

medium

Find the Number of Good Pairs II

You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively.

medium

Find the Maximum Length of a Good Subsequence I

You are given an integer array nums and a non-negative integer k.

medium

Number of Subsequences That Satisfy the Given Sum Condition

You are given an array of integers nums and an integer target.

medium

Destroying Asteroids

You are given an integer mass, which represents the original mass of a planet.

easy

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...

medium

Sum of Absolute Differences in a Sorted Array

You are given an integer array nums sorted in non-decreasing order.

easy

Matrix Similarity After Cyclic Shifts

You are given an m x n integer matrix mat and an integer k.

hard

Maximum Profit from Trading Stocks with Discounts

You are given an integer n, representing the number of employees in a company.

hard

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.

easy

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.

medium

Find Polygon With the Largest Perimeter

You are given an array of positive integers nums of length n.

medium

Find the Duplicate Number

Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.

hard

Parse Lisp Expression

You are given a string expression representing a Lisp-like expression to return the integer value of.

hard

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...

medium

Jump Game VI

You are given a 0-indexed integer array nums and an integer k.

medium

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.

easy

Count Special Quadruplets

Given a 0-indexed integer array nums, return the number of distinct quadruplets (a, b, c, d) such that:

easy

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).

easy

Find Numbers with Even Number of Digits

Given an array nums of integers, return how many of them contain an even number of digits.

easy

Number of Good Pairs

Given an array of integers nums, return the number of good pairs.

hard

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.

hard

Find Edges in Shortest Paths

You are given an undirected weighted graph of n nodes numbered from 0 to n - 1.

medium

Swap For Longest Repeated Character Substring

You are given a string text.

hard

Best Position for a Service Centre

A delivery company wants to build a new service center in a new city.

hard

Restore The Array

A program was supposed to print an array of integers.

easy

Maximum Number of Words You Can Type

There is a malfunctioning keyboard where some letter keys do not work.

medium

Find Mirror Score of a String

You are given a string s.

easy

Distribute Candies Among Children I

You are given two positive integers n and limit.

medium

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.

hard

Minimum Time to Revert Word to Initial State II

You are given a 0-indexed string word and an integer k.

medium

Simplify Path

You are given an absolute path for a Unix-style file system, which always begins with a slash '/'.

hard

Number of Atoms

Given a string formula representing a chemical formula, return the count of each atom.

hard

Separate Squares II

You are given a 2D integer array squares.

easy

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.

hard

Word Ladder

A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ...

medium

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.

easy

Alternating Groups I

There is a circle of red and blue tiles.

medium

Find the Winner of the Circular Game

There are n friends that are playing a game.

hard

Count Anagrams

You are given a string s containing one or more words.

easy

Number of Employees Who Met the Target

There are n employees in a company, numbered from 0 to n - 1.

medium

Shortest Bridge

You are given an n x n binary matrix grid where 1 represents land and 0 represents water.

medium

Largest Number After Mutating Substring

You are given a string num, which represents a large integer.

hard

Number of Excellent Pairs

You are given a 0-indexed positive integer array nums and a positive integer k.

medium

Maximum Subarray Sum With Length Divisible by K

You are given an array of integers nums and an integer k.

medium

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.

easy

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.

hard

Palindrome Partitioning IV

Given a string s, return true if it is possible to split the string s into three non-empty palindromic substrings.

easy

Maximum Units on a Truck

You are assigned to put some amount of boxes onto one truck.

medium

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.

medium

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].

medium

Two City Scheduling

A company is planning to interview 2n people.

medium

Minimum Height Trees

A tree is an undirected graph in which any two vertices are connected by exactly one path.

medium

Avoid Flood in The City

Your country has an infinite number of lakes.

hard

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.

medium

Maximum Value after Insertion

You are given a very large integer n, represented as a string,​​​​​​ and an integer digit x.

hard

Super Egg Drop

You are given k identical eggs and you have access to a building with n floors labeled from 1 to n.

easy

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.

medium

Minimum Substring Partition of Equal Character Frequency

Given a string s, you need to partition it into one or more balanced substrings.

medium

Interval List Intersections

You are given two lists of closed intervals, firstList and secondList, where firstList[i] = [starti, endi] and secondList[j] = [startj, endj].

medium

Bitwise XOR of All Pairings

You are given two 0-indexed arrays, nums1 and nums2, consisting of non-negative integers.

medium

Longest Ideal Subsequence

You are given a string s consisting of lowercase letters and an integer k.

medium

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...

hard

Find X Value of Array II

You are given an array of positive integers nums and a positive integer k.

hard

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.

medium

Binary Subarrays With Sum

Given a binary array nums and an integer goal, return the number of non-empty subarrays with a sum goal.

hard

Minimum Total Distance Traveled

There are some robots and factories on the X-axis.

medium

Maximum Length of Pair Chain

You are given an array of n pairs pairs where pairs[i] = [lefti, righti] and lefti < righti.

hard

Stone Game IV

Alice and Bob take turns playing a game, with Alice starting first.

medium

Describe the Painting

There is a long and thin painting that can be represented by a number line.

medium

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.

hard

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.

hard

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.

easy

Divide Array Into Equal Pairs

You are given an integer array nums consisting of 2 * n integers.

medium

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.

easy

Length of Last Word

Given a string s consisting of words and spaces, return the length of the last word in the string.

medium

Jump Game VII

You are given a 0-indexed binary string s and two integers minJump and maxJump.

medium

Fraction Addition and Subtraction

Given a string expression representing an expression of fraction addition and subtraction, return the calculation result in string format.

easy

Three Divisors

Given an integer n, return true if n has exactly three positive divisors.

easy

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...

medium

Can Make Palindrome from Substring

You are given a string s and array queries where queries[i] = [lefti, righti, ki].

easy

Minimum Number of Operations to Make Elements in Array Distinct

You are given an integer array nums.

easy

Find the Largest Almost Missing Integer

You are given an integer array nums and an integer k.

easy

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...

hard

Minimize OR of Remaining Elements Using Operations

You are given a 0-indexed integer array nums and an integer k.

easy

Make Array Zero by Subtracting Equal Amounts

You are given a non-negative integer array nums.

hard

Apply Operations on Array to Maximize Sum of Squares

You are given a 0-indexed integer array nums and a positive integer k.

medium

Minimum Cost to Set Cooking Time

A generic microwave supports cooking times for: To set the cooking time, you push at most four digits.

hard

Escape the Spreading Fire

You are given a 0-indexed 2D integer array grid of size m x n which represents a field.

medium

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.

hard

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.

medium

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 <=...

easy

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.

medium

Count the Number of Special Characters II

You are given a string word.

medium

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.

easy

Find the Town Judge

In a town, there are n people labeled from 1 to n.

medium

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.

medium

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.

medium

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.

medium

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.

medium

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).

easy

Ant on the Boundary

An ant is on a boundary.

easy

Unique 3-Digit Even Numbers

You are given an array of digits called digits.

easy

Total Distance Traveled

A truck has two fuel tanks.

medium

Minimum Addition to Make Integer Beautiful

You are given two positive integers n and target.

medium

Image Overlap

You are given two images, img1 and img2, represented as binary, square matrices of size n x n.

hard

Count Substrings That Satisfy K-Constraint II

You are given a binary string s and an integer k.

easy

Check if the Sentence Is Pangram

A pangram is a sentence where every letter of the English alphabet appears at least once.

hard

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.

medium

Word Search

Given an m x n grid of characters board and a string word, return true if word exists in the grid.

hard

Cat and Mouse II

A game is played by a cat and a mouse named Cat and Mouse.

medium

Convert an Array Into a 2D Array With Conditions

You are given an integer array nums.

medium

Closest Dessert Cost

You would like to make dessert and are preparing to buy the ingredients.

medium

Find The Original Array of Prefix Xor

You are given an integer array pref of size n.

easy

Divisible and Non-divisible Sums Difference

You are given positive integers n and m.

medium

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.

hard

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.

hard

Longest Common Prefix of K Strings After Removal

You are given an array of strings words and an integer k.

hard

Painting a Grid With Three Different Colors

You are given two integers m and n.

hard

Last Substring in Lexicographical Order

Given a string s, return the last substring of s in lexicographical order.

easy

Reverse Bits

Reverse bits of a given 32 bits unsigned integer.

medium

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.

easy

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.

medium

Maximum Number of Points with Cost

You are given an m x n integer matrix points (0-indexed).

medium

Max Number of K-Sum Pairs

You are given an integer array nums and an integer k.

medium

Check Knight Tour Configuration

There is a knight on an n x n chessboard.

medium

Two Best Non-Overlapping Events

You are given a 0-indexed 2D integer array of events where events[i] = [startTimei, endTimei, valuei].

hard

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.

medium

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.

medium

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).

easy

Count Symmetric Integers

You are given two positive integers low and high.

hard

Minimum Edge Reversals So Every Node Is Reachable

There is a simple directed graph with n nodes labeled from 0 to n - 1.

hard

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.

easy

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.

medium

Longest Subarray of 1's After Deleting One Element

Given a binary array nums, you should delete one element from it.

hard

Find the Number of Possible Ways for an Event

You are given three integers n, x, and y.

hard

Count Beautiful Substrings II

You are given a string s and a positive integer k.

easy

Maximum Area of Longest Diagonal Rectangle

You are given a 2D 0-indexed integer array dimensions.

medium

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...

easy

Maximum Odd Binary Number

You are given a binary string s that contains at least one '1'.

medium

Bitwise ORs of Subarrays

Given an integer array arr, return the number of distinct bitwise ORs of all the non-empty subarrays of arr.

medium

Process String with Special Operations I

You are given a string s consisting of lowercase English letters and the special characters: *, #, and %.

hard

Shortest Path Visiting All Nodes

You have an undirected, connected graph of n nodes labeled from 0 to n - 1.

medium

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.

medium

Time Needed to Inform All Employees

A company has n employees with a unique ID for each employee from 0 to n - 1.

easy

Minimum Time Visiting All Points

On a 2D plane, there are n points with integer coordinates points[i] = [xi, yi].

hard

Cat and Mouse

A game on an undirected graph is played by two players, Mouse and Cat, who alternate turns.

medium

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.

easy

Longest Strictly Increasing or Strictly Decreasing Subarray

You are given an array of integers nums.

medium

Gas Station

There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].

hard

Minimum Money Required Before Transactions

You are given a 0-indexed 2D integer array transactions, where transactions[i] = [costi, cashbacki].

hard

Maximum Score Words Formed by Letters

Given a list of words, list of single letters (might be repeating) and score of every character.

hard

Substring with Concatenation of All Words

You are given a string s and an array of strings words.

medium

Replace Question Marks in String to Minimize Its Value

You are given a string s.

medium

Minimum Operations to Make Median of Array Equal to K

You are given an integer array nums and a non-negative integer k.

medium

Process Tasks Using Servers

You are given two 0-indexed integer arrays servers and tasks of lengths n​​​​​​ and m​​​​​​ respectively.

medium

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.

hard

Count the Number of Arrays with K Matching Adjacent Elements

You are given three integers n, m, k.

medium

Maximum Beauty of an Array After Applying Operation

You are given a 0-indexed array nums and a non-negative integer k.

hard

Sliding Puzzle

On an 2 x 3 board, there are five tiles labeled from 1 to 5, and an empty square represented by 0.

medium

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.

medium

Lexicographically Smallest Equivalent String

You are given two strings of the same length s1 and s2 and a string baseStr.

hard

Maximum Score of Non-overlapping Intervals

You are given a 2D integer array intervals, where intervals[i] = [li, ri, weighti].

hard

Minimum Increments for Target Multiples in an Array

You are given two arrays, nums and target.

medium

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.

medium

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:

easy

Pascal's Triangle II

Given an integer rowIndex, return the rowIndexth (0-indexed) row of the Pascal's triangle.

easy

Majority Element

Given an array nums of size n, return the majority element.

hard

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).

medium

Minimum Deletions to Make Array Beautiful

You are given a 0-indexed integer array nums.

hard

Minimum Edge Weight Equilibrium Queries in a Tree

There is an undirected tree with n nodes labeled from 0 to n - 1.

hard

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.

medium

Number of Burgers with No Waste of Ingredients

Given two integers tomatoSlices and cheeseSlices.

medium

Number of Closed Islands

Given a 2D grid consists of 0s (land) and 1s (water).

hard

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.

medium

Minimum Time to Visit Disappearing Nodes

There is an undirected graph of n nodes.

medium

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.

medium

Minimum Genetic Mutation

A gene string can be represented by an 8-character long string, with choices from 'A', 'C', 'G', and 'T'.

medium

01 Matrix

Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell.

medium

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].

hard

Self Crossing

You are given an array of integers distance.

hard

Maximum Number of Events That Can Be Attended II

You are given an array of events where events[i] = [startDayi, endDayi, valuei].

medium

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.

hard

Frog Jump

A frog is crossing a river.

medium

Pacific Atlantic Water Flow

There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean.

medium

Vowels Game in a String

Alice and Bob are playing a game on a string.

medium

Reward Top K Students

You are given two string arrays positive_feedback and negative_feedback, containing the words denoting positive and negative feedback, respectively.

easy

Distribute Elements Into Two Arrays I

You are given a 1-indexed array of distinct integers nums of length n.

hard

Delete Columns to Make Sorted III

You are given an array of n strings strs, all of the same length.

easy

Zigzag Grid Traversal With Skip

You are given an m x n 2D array grid of positive integers.

medium

Get Watched Videos by Your Friends

There are n people, each person has a unique id between 0 and n-1.

medium

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...

medium

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.

medium

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.

medium

Interleaving String

Given strings s1, s2, and s3, find whether s3 is formed by an interleaving of s1 and s2.

hard

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.

easy

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.

easy

Lexicographically Smallest Palindrome

You are given a string s consisting of lowercase English letters, and you are allowed to perform operations on it.

medium

Reorder Data in Log Files

You are given an array of logs.

hard

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.

easy

Number of Arithmetic Triplets

You are given a 0-indexed, strictly increasing integer array nums and a positive integer diff.

easy

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.

medium

Find All Good Indices

You are given a 0-indexed integer array nums of size n and a positive integer k.

medium

Count Primes

Given an integer n, return the number of prime numbers that are strictly less than n.

easy

Alternating Digit Sum

You are given a positive integer n.

medium

Maximum Sum of Almost Unique Subarray

You are given an integer array nums and two positive integers m and k.

hard

Triples with Bitwise AND Equal To Zero

Given an integer array nums, return the number of AND triples.

medium

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.

hard

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...

hard

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.

medium

Find the Lexicographically Smallest Valid Sequence

You are given two strings word1 and word2.

hard

Power of Heroes

You are given a 0-indexed integer array nums representing the strength of some heroes.

medium

Find Maximum Number of Non Intersecting Substrings

You are given a string word.

hard

Longest Common Suffix Queries

You are given two arrays of strings wordsContainer and wordsQuery.

medium

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.

medium

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.

hard

Minimum Cost to Divide Array Into Subarrays

You are given two integer arrays, nums and cost, of the same size, and an integer k.

medium

Minimum Rectangles to Cover Points

You are given a 2D integer array points, where points[i] = [xi, yi].

medium

Adding Two Negabinary Numbers

Given two numbers arr1 and arr2 in base -2, return the result of adding them together.

hard

Shortest Palindrome

You are given a string s.

hard

Maximum Number of Robots Within Budget

You have n robots.

medium

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.

medium

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.

hard

Minimum Number of Moves to Make Palindrome

You are given a string s consisting only of lowercase English letters.

medium

Apply Operations to Make All Array Elements Equal to Zero

You are given a 0-indexed integer array nums and a positive integer k.

medium

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].

hard

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...

medium

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...

hard

Find the Number of Subarrays Where Boundary Elements Are Maximum

You are given an array of positive integers nums.

medium

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.

easy

Transform Array by Parity

You are given an integer array nums.

medium

Longest Palindromic Substring

Given a string s, return the longest palindromic substring in s.

medium

Find the Longest Equal Subarray

You are given a 0-indexed integer array nums and an integer k.

hard

Contains Duplicate III

You are given an integer array nums and two integers indexDiff and valueDiff.

hard

Maximum Number of Points From Grid Queries

You are given an m x n integer matrix grid and an array queries of size k.

medium

Hash Divided String

You are given a string s of length n and an integer k, where n is a multiple of k.

medium

Rearrange Array to Maximize Prefix Score

You are given a 0-indexed integer array nums.

easy

Lucky Numbers in a Matrix

Given an m x n matrix of distinct numbers, return all lucky numbers in the matrix in any order.

medium

Word Subsets

You are given two string arrays words1 and words2.

hard

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.

easy

Special Positions in a Binary Matrix

Given an m x n binary matrix mat, return the number of special positions in mat.

medium

Minimum Equal Sum of Two Arrays After Replacing Zeros

You are given two arrays nums1 and nums2 consisting of positive integers.

medium

Perfect Squares

Given an integer n, return the least number of perfect square numbers that sum to n.

hard

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.

hard

Candy

There are n children standing in a line.

easy

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...

medium

Zero Array Transformation I

You are given an integer array nums of length n and a 2D array queries, where queries[i] = [li, ri].

hard

Minimum Number of Flips to Convert Binary Matrix to Zero Matrix

Given a m x n binary matrix mat.

hard

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.

medium

Split Array into Fibonacci Sequence

You are given a string of digits num, such as "123456579".

easy

Make The String Great

Given a string s of lower and upper case English letters.

easy

Find the Width of Columns of a Grid

You are given a 0-indexed m x n integer matrix grid.

easy

Count Square Sum Triples

A square triple (a,b,c) is a triple where a, b, and c are integers and a2 + b2 = c2.

hard

Basic Calculator

Given a string s representing a valid expression, implement a basic calculator to evaluate it, and return the result of the evaluation.

medium

The Number of Full Rounds You Have Played

You are participating in an online chess tournament.

hard

Frog Position After T Seconds

Given an undirected tree consisting of n vertices numbered from 1 to n.

easy

Find Most Frequent Vowel and Consonant

You are given a string s consisting of lowercase English letters ('a' to 'z').

hard

Minimum Weighted Subgraph With the Required Paths

You are given an integer n denoting the number of nodes of a weighted directed graph.

easy

Finding 3-Digit Even Numbers

You are given an integer array digits, where each element is a digit.

medium

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...

easy

Minimum Number of Moves to Seat Everyone

There are n availabe seats and n students standing in a room.

medium

Minimum Number of Operations to Make Array Empty

You are given a 0-indexed array nums consisting of positive integers.

medium

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.

easy

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.

medium

Minimum Numbers of Function Calls to Make Target Array

You are given an integer array nums.

easy

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.

hard

Number of Integers With Popcount-Depth Equal to K II

You are given an integer array nums.

easy

Sqrt(x)

Given a non-negative integer x, return the square root of x rounded down to the nearest integer.

medium

Largest Merge Of Two Strings

You are given two strings word1 and word2.

medium

Minimum Number of Arrows to Burst Balloons

There are some spherical balloons taped onto a flat wall that represents the XY-plane.

easy

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,...

medium

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).

hard

Longest Special Path II

You are given an undirected tree rooted at node 0, with n nodes numbered from 0 to n - 1.

hard

Dungeon Game

The demons had captured the princess and imprisoned her in the bottom-right corner of a dungeon.

hard

Earliest Second to Mark Indices II

You are given two 1-indexed integer arrays, nums and, changeIndices, having lengths n and m, respectively.

easy

Maximum Product of Two Digits

You are given a positive integer n.

easy

Thousand Separator

Given an integer n, add a dot (".") as the thousands separator and return it in string format.

easy

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.

medium

Minimum Elements to Add to Form a Given Sum

You are given an integer array nums and two integers limit and goal.

medium

Minimum Operations to Make All Array Elements Equal

You are given an array nums consisting of positive integers.

medium

Count Unreachable Pairs of Nodes in an Undirected Graph

You are given an integer n.

easy

Shortest Distance to Target String in a Circular Array

You are given a 0-indexed circular string array words and a string target.

easy

Pascal's Triangle

Given an integer numRows, return the first numRows of Pascal's triangle.

hard

Find the Closest Palindrome

Given a string n representing an integer, return the closest integer (not including itself), which is a palindrome.

hard

Find the Maximum Sequence Value of Array

You are given an integer array nums and a positive integer k.

medium

Minimum Number of Seconds to Make Mountain Height Zero

You are given an integer mountainHeight denoting the height of a mountain.

medium

Heaters

Winter is coming!

medium

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.

medium

The Number of Beautiful Subsets

You are given an array nums of positive integers and a positive integer k.

medium

Minesweeper

Let's play the minesweeper game (Wikipedia, online game)!

medium

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.

medium

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.

easy

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.

medium

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.

hard

Race Car

Your car starts at position 0 and speed +1 on an infinite number line.

medium

Find Longest Special Substring That Occurs Thrice II

You are given a string s that consists of lowercase English letters.

hard

Find the Minimum Area to Cover All Ones II

You are given a 2D binary array grid.

medium

Search in Rotated Sorted Array II

There is an integer array nums sorted in non-decreasing order (not necessarily with distinct values).

medium

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.

easy

Find Resultant Array After Removing Anagrams

You are given a 0-indexed string array words, where words[i] consists of lowercase English letters.

hard

Find Minimum in Rotated Sorted Array II

Suppose an array of length n sorted in ascending order is rotated between 1 and n times.

easy

Counter II

Write a function createCounter.

medium

Maximize Happiness of Selected Children

You are given an array happiness of length n, and a positive integer k.

medium

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.

easy

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.

medium

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...

easy

Prime In Diagonal

You are given a 0-indexed two-dimensional integer array nums.

hard

Palindrome Rearrangement Queries

You are given a 0-indexed string s having an even length n.

medium

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...

medium

Diagonal Traverse

Given an m x n matrix mat, return an array of all the elements of the array in a diagonal order.

medium

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.

medium

Minimum Deletions to Make String K-Special

You are given a string word and an integer k.

easy

Minimum Sum of Mountain Triplets I

You are given a 0-indexed array nums of integers.

easy

Maximum Difference Between Adjacent Elements in a Circular Array

Given a circular array nums, find the maximum absolute difference between adjacent elements.

medium

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.

medium

Minimum Operations to Make Binary Array Elements Equal to One I

You are given a binary array nums.

easy

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.

medium

Maximum Average Pass Ratio

There is a school that has classes of students and each class will be having a final exam.

easy

Ransom Note

Given two strings ransomNote and magazine, return true if ransomNote can be constructed by using the letters from magazine and false otherwise.

medium

Number of Ways to Buy Pens and Pencils

You are given an integer total indicating the amount of money you have.

medium

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).

easy

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.

easy

Minimum Value to Get Positive Step by Step Sum

Given an array of integers nums, you start with an initial positive value startValue.

medium

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.

medium

Find Minimum Time to Reach Last Room I

There is a dungeon with n x m rooms arranged as a grid.

hard

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.

medium

Maximum Star Sum of a Graph

There is an undirected graph consisting of n nodes numbered from 0 to n - 1.

medium

Minimum Operations to Make the Array Alternating

You are given a 0-indexed array nums consisting of n positive integers.

hard

Construct Target Array With Multiple Sums

You are given an array target of n integers.

medium

House Robber

You are a professional robber planning to rob houses along a street.

easy

Find the Key of the Numbers

You are given three positive integers num1, num2, and num3.

medium

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.

hard

Maximize Score After N Operations

You are given nums, an array of positive integers of size 2 * n.

medium

Partition Array Such That Maximum Difference Is K

You are given an integer array nums and an integer k.

medium

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.

medium

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...

medium

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...

easy

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.

medium

Maximum Frequency of an Element After Performing Operations I

You are given an integer array nums and two integers k and numOperations.

easy

Rearrange Spaces Between Words

You are given a string text of words that are placed among some number of spaces.

medium

Water Bottles II

You are given two integers numBottles and numExchange.

hard

Minimum Weighted Subgraph With the Required Paths II

You are given an undirected weighted tree with n nodes, numbered from 0 to n - 1.

easy

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...

medium

Minimum Operations to Convert All Elements to Zero

You are given an array nums of size n, consisting of non-negative integers.

easy

Is Subsequence

Given two strings s and t, return true if s is a subsequence of t, or false otherwise.

medium

Minimum Absolute Difference Between Elements With Constraint

You are given a 0-indexed integer array nums and an integer x.

medium

Stone Game VI

Alice and Bob take turns playing a game, with Alice starting first.

easy

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.

medium

Minimum Absolute Sum Difference

You are given two positive integer arrays nums1 and nums2, both of length n.

medium

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.

easy

Count Partitions with Even Sum Difference

You are given an integer array nums of length n.

medium

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).

medium

Count Alternating Subarrays

You are given a binary array nums.

medium

Find The First Player to win K Games in a Row

A competition consists of n players numbered from 0 to n - 1.

medium

Maximize Greatness of an Array

You are given a 0-indexed integer array nums.

easy

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.

easy

Maximum Unique Subarray Sum After Deletion

You are given an integer array nums.

medium

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.

easy

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.

medium

Prime Subtraction Operation

You are given a 0-indexed integer array nums of length n.

easy

Count the Number of Vowel Strings in Range

You are given a 0-indexed array of string words and two integers left and right.

medium

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.

easy

Number of Distinct Averages

You are given a 0-indexed integer array nums of even length.

medium

Optimal Division

You are given an integer array nums.

hard

Memoize II

Given a function fn, return a memoized version of that function.

easy

Find Minimum Operations to Make All Elements Divisible by Three

You are given an integer array nums.

medium

Asteroid Collision

We are given an array asteroids of integers representing asteroids in a row.

medium

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.

easy

Crawler Log Folder

A file system keeps a log each time some user performs a change folder operation.

medium

Escape The Ghosts

You are playing a simplified PAC-MAN game on an infinite 2-D grid.

medium

Extra Characters in a String

You are given a 0-indexed string s and a dictionary of words dictionary.

easy

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.

medium

Coin Change

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

medium

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.

medium

Find Minimum Cost to Remove Array Elements

You are given an integer array nums.

easy

Make Array Elements Equal to Zero

You are given an integer array nums.

easy

Subarrays Distinct Element Sum of Squares I

You are given a 0-indexed integer array nums.

medium

Exclusive Time of Functions

On a single-threaded CPU, we execute a program containing n functions.

hard

IPO

Suppose a startup will begin its IPO soon.

hard

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...

medium

Find Kth Largest XOR Coordinate Value

You are given a 2D matrix of size m x n, consisting of non-negative integers.

medium

Minimum Number of Valid Strings to Form Target I

You are given an array of strings words and a string target.

easy

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.

medium

Spiral Matrix II

Given a positive integer n, generate an n x n matrix filled with elements from 1 to n2 in spiral order.

hard

Number of Submatrices That Sum to Target

Given a matrix and a target, return the number of non-empty submatrices that sum to target.

medium

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.

easy

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...

hard

Maximum Area Rectangle With Point Constraints II

There are n points on an infinite plane.

easy

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).

easy

Find the Integer Added to Array I

You are given two arrays of equal length, nums1 and nums2.

easy

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.

medium

Minimum Number of Changes to Make Binary String Beautiful

You are given a 0-indexed binary string s having an even length.

medium

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.

hard

Check If It Is a Good Array

Given an array nums of positive integers.

hard

Cycle Length Queries in a Tree

You are given an integer n.

easy

Goal Parser Interpretation

You own a Goal Parser that can interpret a string command.

hard

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...

easy

Minimum Number of Pushes to Type Word I

You are given a string word containing distinct lowercase English letters.

hard

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.

easy

Find Pivot Index

Given an array of integers nums, calculate the pivot index of this array.

easy

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.

hard

Minimum Time to Make Array Sum At Most x

You are given two 0-indexed integer arrays nums1 and nums2 of equal length.

hard

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.

medium

Closest Divisors

Given an integer num, find the closest two integers in absolute difference whose product equals num + 1 or num + 2.

easy

Richest Customer Wealth

You are given an m x n integer grid accounts where accounts[i][j] is the amount of money the i​​​​​​​​​​​th​​​​ customer has in the j​​​​​​​​​​​th​​​​ bank.

medium

Find Peak Element

A peak element is an element that is strictly greater than its neighbors.

hard

Number of Music Playlists

Your music player contains n different songs.

medium

Shortest Path in Binary Matrix

Given an n x n binary matrix grid, return the length of the shortest clear path in the matrix.

medium

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.

medium

Apply Operations to Make String Empty

You are given a string s.

easy

Number of Students Doing Homework at a Given Time

Given two integer arrays startTime and endTime and given an integer queryTime.

medium

Minimum Area Rectangle II

You are given an array of points in the X-Y plane points where points[i] = [xi, yi].

hard

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.

medium

Steps to Make Array Non-decreasing

You are given a 0-indexed integer array nums.

hard

Count the Number of Incremovable Subarrays II

You are given a 0-indexed array of positive integers nums.

medium

Shopping Offers

In an online store, there are n items to sell.

easy

Hamming Distance

The Hamming distance between two integers is the number of positions at which the corresponding bits are different.

medium

Minimize XOR

Given two positive integers num1 and num2, find the positive integer x such that: Note that XOR is the bitwise XOR operation.

medium

Sum of Beauty of All Substrings

The beauty of a string is the difference in frequencies between the most frequent and least frequent characters.

hard

Equal Sum Grid Partition II

You are given an m x n matrix grid of positive integers.

easy

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.

medium

Circular Permutation in Binary Representation

Given 2 integers n and start.

medium

Convert to Base -2

Given an integer n, return a binary string representing its representation in base -2.

medium

Maximum Bags With Full Capacity of Rocks

You have n bags numbered from 0 to n - 1.

easy

Find the K-or of an Array

You are given an integer array nums, and an integer k.

medium

Rabbits in Forest

There is a forest with an unknown number of rabbits.

medium

Distribute Candies Among Children II

You are given two positive integers n and limit.

medium

Maximum Number of Moves in a Grid

You are given a 0-indexed m x n matrix grid consisting of positive integers.

medium

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...

medium

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.

hard

Rectangle Area II

You are given a 2D array of axis-aligned rectangles.

medium

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.

medium

Prime Pairs With Target Sum

You are given an integer n.

medium

Plates Between Candles

There is a long table with a line of plates and candles arranged on top of it.

hard

Car Fleet II

There are n cars traveling at different speeds in the same direction along a one-lane road.

easy

Create Target Array in the Given Order

Given two arrays of integers nums and index.

easy

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...

easy

Longest Continuous Increasing Subsequence

Given an unsorted array of integers nums, return the length of the longest continuous increasing subsequence (i.e.

medium

Spiral Matrix

Given an m x n matrix, return all elements of the matrix in spiral order.

medium

Sum of Matrix After Queries

You are given an integer n and a 0-indexed 2D array queries where queries[i] = [typei, indexi, vali].

hard

Orderly Queue

You are given a string s and an integer k.

easy

Split a String in Balanced Strings

Balanced strings are those that have an equal quantity of 'L' and 'R' characters.

medium

Reordered Power of 2

You are given an integer n.

hard

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.

medium

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...

medium

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.

medium

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.

medium

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'.

easy

Min Cost Climbing Stairs

You are given an integer array cost where cost[i] is the cost of ith step on a staircase.

hard

Count the Number of Houses at a Certain Distance II

You are given three positive integers n, x, and y.

medium

Minimum Add to Make Parentheses Valid

A parentheses string is valid if and only if: You are given a parentheses string s.

hard

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.

hard

Valid Arrangement of Pairs

You are given a 0-indexed 2D integer array pairs where pairs[i] = [starti, endi].

easy

Determine if String Halves Are Alike

You are given a string s of even length.

medium

Dota2 Senate

In the world of Dota2, there are two parties: the Radiant and the Dire.

hard

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.

hard

Tag Validator

Given a string representing a code snippet, implement a tag validator to parse the code and return whether it is valid.

easy

Find Indices of Stable Mountains

There are n mountains in a row, and each mountain has a height.

hard

Maximum and Minimum Sums of at Most Size K Subarrays

You are given an integer array nums and a positive integer k.

hard

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.

medium

Last Stone Weight II

You are given an array of integers stones where stones[i] is the weight of the ith stone.

easy

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.

hard

Kth Smallest Number in Multiplication Table

Nearly everyone has used the Multiplication Table.

medium

Monotone Increasing Digits

An integer has monotone increasing digits if and only if each pair of adjacent digits x and y satisfy x <= y.

medium

Find Score of an Array After Marking All Elements

You are given an array nums consisting of positive integers.

medium

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.

medium

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.

easy

Substring Matching Pattern

You are given a string s and a pattern string p, where p contains exactly one '*' character.

easy

Water Bottles

There are numBottles water bottles that are initially full of water.

easy

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).

hard

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.

medium

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.

hard

First Missing Positive

Given an unsorted integer array nums.

easy

Available Captures for Rook

You are given an 8 x 8 matrix representing a chessboard.

medium

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.

medium

Find the Maximum Number of Elements in Subset

You are given an array of positive integers nums.

easy

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).

easy

Find First Palindromic String in the Array

Given an array of strings words, return the first palindromic string in the array.

medium

Find the City With the Smallest Number of Neighbors at a Threshold Distance

There are n cities numbered from 0 to n-1.

medium

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].

easy

Valid Perfect Square

Given a positive integer num, return true if num is a perfect square or false otherwise.

medium

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.

hard

Minimum Stability Factor of Array

You are given an integer array nums and an integer maxC.

easy

Minimum Number of Chairs in a Waiting Room

You are given a string s.

medium

Groups of Special-Equivalent Strings

You are given an array of strings of the same length words.

medium

Taking Maximum Energy From the Mystic Dungeon

In a mystic dungeon, n magicians are standing in a line.

easy

Slowest Key

A newly designed keypad was tested, where a tester pressed a sequence of n keys, one at a time.

easy

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.

hard

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.

medium

Find Good Days to Rob the Bank

You and a gang of thieves are planning on robbing a bank.

medium

Maximum Number of Jumps to Reach the Last Index

You are given a 0-indexed array nums of n integers and an integer target.

medium

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.

easy

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].

medium

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].

easy

Find if Digit Game Can Be Won

You are given an array of positive integers nums.

hard

Maximum Difference Between Even and Odd Frequency II

You are given a string s and an integer k.

medium

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...

hard

Find Subarray With Bitwise OR Closest to K

You are given an array nums and an integer k.

hard

Count The Repetitions

We define str = [s, n] as the string str which consists of the string s concatenated n times.

medium

Smallest Value of the Rearranged Number

You are given an integer num.

medium

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'.

easy

Palindrome Linked List

Check whether the values in a singly-linked list read the same forwards and backwards.

hard

Merge K Sorted Linked Lists

Merge k independently sorted linked lists into a single sorted linked list.

medium

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.

easy

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.

easy

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.

medium

Insert into a Binary Search Tree

Insert a new value into a binary search tree while preserving its ordering property.

easy

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.

easy

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.

easy

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.

easy

Invert Binary Tree

Flip a binary tree into its mirror image by swapping every node's left and right children.

easy

Remove Duplicates From a Sorted Linked List

Collapse consecutive duplicate values in a sorted singly-linked list so each value appears once.

medium

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.

easy

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.

medium

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.

medium

Maximum Subarray

Find the contiguous subarray with the largest sum.

easy

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.

medium

Reorder a Linked List

Rearrange a singly-linked list by alternating nodes from the front and the back until they meet in the middle.

medium

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.

medium

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.

medium

Beautiful Towers II

You are given a 0-indexed array maxHeights of n integers.

medium

Maximum Width Ramp

A ramp in an integer array nums is a pair (i, j) for which i < j and nums[i] <= nums[j].

medium

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.

hard

Smallest Sufficient Team

In a project, you have a list of required skills req_skills, and a list of people.

hard

Minimize Manhattan Distances

You are given an array points representing integer coordinates of some points on a 2D plane, where points[i] = [xi, yi].

hard

Bus Routes

You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever.

medium

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...

easy

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.

medium

Minimize Length of Array Using Operations

You are given a 0-indexed integer array nums containing positive integers.

easy

Minimum Amount of Time to Fill Cups

You have a water dispenser that can dispense cold, warm, and hot water.

medium

Minimum Swaps to Sort by Digit Sum

You are given an array nums of distinct positive integers.

hard

Check If Digits Are Equal in String After Operations II

You are given a string s consisting of digits.

medium

Maximum XOR After Operations

You are given a 0-indexed integer array nums.

hard

Find Array Given Subset Sums

You are given an integer n representing the length of an unknown array that you are trying to recover.

easy

Minimum Operations to Collect Elements

You are given an array nums of positive integers and an integer k.

easy

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.

medium

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.

medium

Total Characters in String After Transformations I

You are given a string s and an integer t, representing the number of transformations to perform.

medium

Longest Common Subsequence

Given two strings text1 and text2, return the length of their longest common subsequence.

medium

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.

hard

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.

medium

Maximum Rows Covered by Columns

You are given an m x n binary matrix matrix and an integer numSelect.

medium

Decode Ways

You have intercepted a secret message encoded as a string of numbers.

easy

Decompress Run-Length Encoded List

We are given a list nums of integers representing a list compressed with run-length encoding.

medium

Sum of Beauty in the Array

You are given a 0-indexed integer array nums.

medium

Fraction to Recurring Decimal

Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.

medium

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...

hard

Distribute Repeating Integers

You are given an array of n integers, nums, where there are at most 50 unique values in the array.

hard

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.

hard

Difference Between Maximum and Minimum Price Sum

There exists an undirected and initially unrooted tree with n nodes indexed from 0 to n - 1.

medium

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...

easy

Hexadecimal and Hexatrigesimal Conversion

You are given an integer n.

hard

Maximum Fruits Harvested After at Most K Steps

Fruits are available at some positions on an infinite x-axis.

hard

Count Almost Equal Pairs II

Attention: In this version, the number of operations that can be performed, has been increased to twice.

easy

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.

hard

Cracking the Safe

There is a safe protected by a password.

hard

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.

easy

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 ?).

medium

Maximum Number of Occurrences of a Substring

Given a string s, return the maximum number of occurrences of any substring under the following rules:

medium

String Without AAA or BBB

Given two integers a and b, return any string s such that:

hard

Tallest Billboard

You are installing a billboard and want it to have the largest height.

easy

Maximum Value of an Ordered Triplet I

You are given a 0-indexed integer array nums.

hard

Count Numbers with Non-Decreasing Digits

You are given two integers, l and r, represented as strings, and an integer b.

medium

Number of Substrings Containing All Three Characters

Given a string s consisting only of characters a, b and c.

medium

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.

hard

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).

medium

Keys and Rooms

There are n rooms labeled from 0 to n - 1 and all the rooms are locked except for room 0.

easy

Apple Redistribution into Boxes

You are given an array apple of size n and an array capacity of size m.

easy

Number of Different Integers in a String

You are given a string word that consists of digits and lowercase English letters.

medium

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.

medium

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.

hard

Split Array With Same Average

You are given an integer array nums.

hard

Couples Holding Hands

There are n couples sitting in 2n seats arranged in a row and want to hold hands.

medium

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.

hard

Sum of Distances in Tree

There is an undirected connected tree with n nodes labeled from 0 to n - 1 and n - 1 edges.

medium

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.

medium

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.

easy

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.

medium

Maximum Number of Groups Entering a Competition

You are given a positive integer array grades which represents the grades of students in a university.

medium

Lexicographically Smallest String After Substring Operation

Given a string s consisting of lowercase English letters.

medium

Merge Triplets to Form Target Triplet

A triplet is an array of three integers.

hard

Find XOR Sum of All Pairs Bitwise AND

The XOR sum of a list is the bitwise XOR of all its elements.

easy

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".

medium

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].

hard

Longest Increasing Subsequence II

You are given an integer array nums and an integer k.

hard

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.

easy

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.

hard

Maximize Sum of Weights after Edge Removals

There exists an undirected tree with n nodes numbered 0 to n - 1.

medium

Make K-Subarray Sums Equal

You are given a 0-indexed integer array arr and an integer k.

medium

Splitting a String Into Descending Consecutive Values

You are given a string s that consists of only digits.

medium

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.

medium

Maximum Non Negative Product in a Matrix

You are given a m x n matrix grid.

hard

Maximum Balanced Subsequence Sum

You are given a 0-indexed integer array nums.

medium

Remove Duplicate Letters

Given a string s, remove duplicate letters so that every letter appears once and only once.

hard

Count Different Palindromic Subsequences

Given a string s, return the number of different non-empty palindromic subsequences in s.

hard

Preimage Size of Factorial Zeroes Function

Let f(x) be the number of zeroes at the end of x!.

hard

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.

medium

Most Profit Assigning Work

You have n jobs and m workers.

easy

Find the Number of Good Pairs I

You are given 2 integer arrays nums1 and nums2 of lengths n and m respectively.

easy

Search Insert Position

Given a sorted array of distinct integers and a target value, return the index if the target is found.

hard

Find the Maximum Sum of Node Values

There exists an undirected tree with n nodes numbered 0 to n - 1.

hard

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.

easy

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.

medium

Sender With Largest Word Count

You have a chat log of n messages.

easy

Reformat Phone Number

You are given a phone number as a string number.

medium

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.

medium

Minimum Size Subarray in Infinite Array

You are given a 0-indexed array nums and an integer target.

easy

Largest 3-Same-Digit Number in String

You are given a string num representing a large integer.

medium

Find Minimum in Rotated Sorted Array

Suppose an array of length n sorted in ascending order is rotated between 1 and n times.

medium

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.

medium

Number of Restricted Paths From First to Last Node

There is an undirected weighted connected graph.

medium

Delete and Earn

You are given an integer array nums.

hard

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.

medium

Target Sum

You are given an integer array nums and an integer target.

medium

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].

hard

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.

easy

Longest Common Prefix

Write a function to find the longest common prefix string amongst an array of strings.

hard

Count the Number of Powerful Integers

You are given three integers start, finish, and limit.

medium

Sequential Digits

An integer has sequential digits if and only if each digit in the number is one more than the previous digit.

medium

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.

easy

Sum of Unique Elements

You are given an integer array nums.

medium

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...

medium

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).

medium

Minimum Moves to Make Array Complementary

You are given an integer array nums of even length n and an integer limit.

medium

Number of Dice Rolls With Target Sum

You have n dice, and each dice has k faces numbered from 1 to k.

medium

Relocate Marbles

You are given a 0-indexed integer array nums representing the initial positions of some marbles.

medium

Intervals Between Identical Elements

You are given a 0-indexed array of n integers arr.

medium

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...

medium

Ugly Number II

An ugly number is a positive integer whose prime factors are limited to 2, 3, and 5.

easy

Count Days Spent Together

Alice and Bob are traveling to Rome for separate business meetings.

hard

Manhattan Distances of All Arrangements of Pieces

You are given three integers m, n, and k.

hard

Closest Subsequence Sum

You are given an integer array nums and an integer goal.

easy

Rearrange Characters to Make Target String

You are given two 0-indexed strings s and target.

easy

Count Good Triplets

Given an array of integers arr, and three integers a, b and c.

hard

Check if There Is a Valid Parentheses String Path

A parentheses string is a non-empty string consisting only of '(' and ')'.

easy

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.

easy

Valid Mountain Array

Given an array of integers arr, return true if and only if it is a valid mountain array.

medium

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.

hard

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...

medium

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.

medium

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.

easy

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.

hard

Find the Sum of the Power of All Subsequences

You are given an integer array nums of length n and a positive integer k.

medium

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:

easy

String Matching in an Array

Given an array of string words, return all strings in words that are a substring of another word.

medium

Domino and Tromino Tiling

You have two types of tiles: a 2 x 1 domino shape and a tromino shape.

hard

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...

medium

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.

medium

Count of Interesting Subarrays

You are given a 0-indexed integer array nums, an integer modulo, and an integer k.

medium

Find the Power of K-Size Subarrays II

You are given an array of integers nums of length n and a positive integer k.

easy

Ugly Number

An ugly number is a positive integer which does not have a prime factor other than 2, 3, and 5.

hard

Find Longest Awesome Substring

You are given a string s.

medium

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.

medium

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.

hard

Longest Increasing Path in a Matrix

Given an m x n integers matrix, return the length of the longest increasing path in matrix.

medium

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.

easy

Maximum Sum With Exactly K Elements

You are given a 0-indexed integer array nums and an integer k.

easy

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...

easy

Make Two Arrays Equal by Reversing Subarrays

You are given two integer arrays of equal length target and arr.

medium

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.

easy

Sort Even and Odd Indices Independently

You are given a 0-indexed integer array nums.

medium

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.

hard

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.

medium

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.

hard

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.

hard

Minimum Insertion Steps to Make a String Palindrome

Given a string s.

medium

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.

medium

Closest Equal Element Queries

You are given a circular array nums and an array queries.

medium

Solve the Equation

Solve a given equation and return the value of 'x' in the form of a string "x=#value".

hard

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...

hard

Minimum Deletions to Make Array Divisible

You are given two positive integer arrays nums and numsDivide.

medium

Count Collisions of Monkeys on a Polygon

There is a regular convex polygon with n vertices.

medium

Construct the Longest New String

You are given three integers x, y, and z.

medium

Sort the Students by Their Kth Score

There is a class with m students and n exams.

medium

Maximum Number of Distinct Elements After Operations

You are given an integer array nums and an integer k.

medium

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.

easy

Check if All the Integers in a Range Are Covered

You are given a 2D integer array ranges and two integers left and right.

easy

Number of Beautiful Pairs

You are given a 0-indexed integer array nums.

medium

Form Array by Concatenating Subarrays of Another Array

You are given a 2D integer array groups of length n.

easy

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.

hard

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.

easy

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.

easy

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.

easy

Max Consecutive Ones

Given a binary array nums, return the maximum number of consecutive 1's in the array.

easy

Maximum Height of a Triangle

You are given two integers red and blue representing the count of red and blue colored balls.

easy

Sleep

Given a positive integer millis, write an asynchronous function that sleeps for millis milliseconds.

medium

Minimum Difference Between Largest and Smallest Value in Three Moves

You are given an integer array nums.

medium

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).

easy

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.

medium

Check if it is Possible to Split Array

You are given an array nums of length n and an integer m.

hard

Smallest Range Covering Elements from K Lists

You have k lists of sorted integers in non-decreasing order.

hard

Minimum XOR Sum of Two Arrays

You are given two integer arrays nums1 and nums2 of length n.

medium

Number of Boomerangs

You are given n points in the plane that are all distinct, where points[i] = [xi, yi].

hard

Maximum Score of a Good Subarray

You are given an array of integers nums (0-indexed) and an integer k.

medium

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.

hard

Word Ladder II

A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ...

easy

Transformed Array

You are given an integer array nums that represents a circular array.

easy

Greatest Common Divisor of Strings

For two strings s and t, we say "t divides s" if and only if s = t + t + t + ...

easy

Positions of Large Groups

In a string s of lowercase letters, these letters form consecutive groups of the same character.

medium

Disconnect Path in a Binary Matrix by at Most One Flip

You are given a 0-indexed m x n binary matrix grid.

hard

Largest Palindrome Product

Given an integer n, return the largest palindromic integer that can be represented as the product of two n-digits integers.

easy

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.

medium

Longest Common Prefix Between Adjacent Strings After Removals

You are given an array of strings words.

easy

Chunk Array

Given an array arr and a chunk size size, return a chunked array.

easy

Smallest Index With Digit Sum Equal to Index

You are given an integer array nums.

easy

License Key Formatting

You are given a license key represented as a string s that consists of only alphanumeric characters and dashes.

medium

Smallest Subarrays With Maximum Bitwise OR

You are given a 0-indexed array nums of length n, consisting of non-negative integers.

medium

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.

easy

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.

hard

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].

medium

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.

medium

Earliest Finish Time for Land and Water Rides II

You are given two categories of theme park attractions: land rides and water rides.

hard

Count Subtrees With Max Distance Between Cities

There are n cities numbered from 1 to n.

easy

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.

easy

Longest Even Odd Subarray With Threshold

You are given a 0-indexed integer array nums and an integer threshold.

medium

Maximize Amount After Two Days of Conversions

You are given a string initialCurrency, and you start with 1.0 of initialCurrency.

easy

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...

easy

Last Visited Integers

Given an integer array nums where nums[i] is either a positive integer or -1.

easy

Remove Palindromic Subsequences

You are given a string s consisting only of letters 'a' and 'b'.

medium

Partition Array for Maximum Sum

Given an integer array arr, partition the array into (contiguous) subarrays of length at most k.

easy

Maximum Difference by Remapping a Digit

You are given an integer num.

hard

Minimum Amount of Damage Dealt to Bob

You are given an integer power and two integer arrays damage and health, both having length n.

easy

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.

medium

Stone Game IX

Alice and Bob continue their games with stones.

medium

Decremental String Concatenation

You are given a 0-indexed array words containing n strings.

medium

Maximum Sum of Distinct Subarrays With Length K

You are given an integer array nums and an integer k.

easy

Smallest Divisible Digit Product I

You are given two integers n and t.

medium

Furthest Building You Can Reach

You are given an integer array heights representing the heights of buildings, some bricks, and some ladders.

medium

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...

easy

Add to Array-Form of Integer

The array-form of an integer num is an array representing its digits in left to right order.

easy

Last Stone Weight

You are given an array of integers stones where stones[i] is the weight of the ith stone.

medium

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.

medium

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.

easy

Excel Sheet Column Title

Given an integer columnNumber, return its corresponding column title as it appears in an Excel sheet.

easy

Sum of Variable Length Subarrays

You are given an integer array nums of size n.

hard

Find the K-th Character in String Game II

Alice and Bob are playing a game.

medium

Difference Between Ones and Zeros in Row and Column

You are given a 0-indexed m x n binary matrix grid.

hard

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].

easy

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.

medium

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.

medium

Shift Distance Between Two Strings

You are given two strings s and t of the same length, and two integer arrays nextCost and previousCost.

easy

Climbing Stairs

You are climbing a staircase.

easy

Maximum Subarray With Equal Products

You are given an array of positive integers nums.

medium

Zero Array Transformation III

You are given an integer array nums of length n and a 2D array queries where queries[i] = [li, ri].

medium

Digit Operations to Make Two Integers Equal

You are given two integers n and m that consist of the same number of digits.

hard

Graph Connectivity With Threshold

We have n cities labeled from 1 to n.

easy

Lemonade Change

At a lemonade stand, each lemonade costs $5.

hard

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.

medium

Earliest Second to Mark Indices I

You are given two 1-indexed integer arrays, nums and, changeIndices, having lengths n and m, respectively.

medium

Friends Of Appropriate Ages

There are n persons on a social media website.

medium

Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values

You are given two integer arrays x and y, each of length n.

medium

Number of Black Blocks

You are given two integers m and n representing the dimensions of a 0-indexed m x n grid.

medium

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.

medium

Resulting String After Adjacent Removals

You are given a string s consisting of lowercase English letters.

hard

Shortest Cycle in a Graph

There is a bi-directional graph with n vertices, where each vertex is labeled from 0 to n - 1.

easy

Split Strings by Separator

Given an array of strings words and a character separator, split each string in words by separator.

medium

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.

medium

Permutations

Given an array nums of distinct integers, return all the possible permutations.

hard

Permutation Sequence

The set [1, 2, 3, ..., n] contains a total of n!

medium

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.

medium

First Completely Painted Row or Column

You are given a 0-indexed integer array arr, and an m x n integer matrix mat.

hard

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...

easy

Can Place Flowers

You have a long flowerbed in which some of the plots are planted, and some are not.

medium

Minimize Maximum Pair Sum in Array

The pair sum of a pair (a,b) is equal to a + b.

medium

Course Schedule

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.

hard

Number of Ways to Separate Numbers

You wrote down many positive integers in a string called num.

medium

Minimum Adjacent Swaps to Alternate Parity

You are given an array nums of distinct integers.

medium

2 Keys Keyboard

There is only one character 'A' on the screen of a notepad.

medium

Largest Palindromic Number

You are given a string num consisting of digits only.

hard

Largest Color Value in a Directed Graph

There is a directed graph of n colored nodes and m edges.

hard

Palindrome Partitioning III

You are given a string s containing lowercase letters and an integer k.

medium

Number of Strings Which Can Be Rearranged to Contain Substring

You are given an integer n.

medium

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.

hard

Cherry Pickup

You are given an n x n grid representing a field of cherries, each cell is one of three possible integers.

hard

Smallest Good Base

Given an integer n represented as a string, return the smallest good base of n.

medium

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.

hard

Find Sum of Array Product of Magical Sequences

You are given two integers, m and k, and an integer array nums.

easy

Find the Distinct Difference Array

You are given a 0-indexed array nums of length n.

medium

Sort Characters By Frequency

Given a string s, sort it in decreasing order based on the frequency of the characters.

hard

Sorted GCD Pair Queries

You are given an integer array nums of length n and an integer array queries.

hard

Minimum Cost to Merge Stones

There are n piles of stones arranged in a row.

medium

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.

medium

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.

hard

Minimum Degree of a Connected Trio in a Graph

You are given an undirected graph.

medium

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.

easy

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.

medium

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...

easy

Largest Number At Least Twice of Others

You are given an integer array nums where the largest integer is unique.

medium

Maximum Points After Enemy Battles

You are given an integer array enemyEnergies denoting the energy values of various enemies.

medium

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.

medium

Make Array Non-decreasing

You are given an integer array nums.

medium

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.

easy

Counting Words With a Given Prefix

You are given an array of strings words and a string pref.

hard

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...

medium

Report Spam Message

You are given an array of strings message and an array of strings bannedWords.

easy

Redistribute Characters to Make All Strings Equal

You are given an array of strings words (0-indexed).

medium

Pow(x, n)

Implement pow(x, n), which calculates x raised to the power n (i.e., xn).

medium

Edit Distance

Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2.

easy

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.

medium

Remove Sub-Folders from the Filesystem

Given a list of folders folder, return the folders after removing all sub-folders in those folders.

easy

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.

easy

Largest Number After Digit Swaps by Parity

You are given a positive integer num.

hard

Minimum Number of Taps to Open to Water a Garden

There is a one-dimensional garden on the x-axis.

hard

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.

medium

Open the Lock

You have a lock in front of you with 4 circular wheels.

hard

Count K-Subsequences of a String With Maximum Beauty

You are given a string s and an integer k.

hard

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.

hard

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.

easy

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.

medium

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.

medium

Count of Substrings Containing Every Vowel and K Consonants II

You are given a string word and a non-negative integer k.

medium

Minimum Number of Operations to Reinitialize a Permutation

You are given an even integer n​​​​​​.

medium

Most Frequent IDs

The problem involves tracking the frequency of IDs in a collection that changes over time.

medium

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.

easy

Shortest Subarray With OR at Least K I

You are given an array nums of non-negative integers and an integer k.

hard

Longest Valid Parentheses

Given a string containing just the characters '(' and ')', return the length of the longest valid (well-formed) parentheses substring.

medium

Count Almost Equal Pairs I

You are given an array nums consisting of positive integers.

medium

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.

easy

Count the Digits That Divide a Number

Given an integer num, return the number of digits in num that divide num.

hard

Number of Paths with Max Score

You are given a square board of characters.

hard

Lexicographically Smallest String After Adjacent Removals

You are given a string s consisting of lowercase English letters.

easy

Minimum Number Game

You are given a 0-indexed integer array nums of even length and there is also an empty array arr.

medium

Count the Number of Good Subarrays

Given an integer array nums and an integer k, return the number of good subarrays of nums.

medium

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].

hard

Number of Ways to Reorder Array to Get Same BST

Given an array nums that represents a permutation of integers from 1 to n.

medium

Walking Robot Simulation

A robot on an infinite XY-plane starts at point (0, 0) facing north.

hard

Shortest Common Supersequence

Given two strings str1 and str2, return the shortest string that has both str1 and str2 as subsequences.

easy

Find Subsequence of Length K With the Largest Sum

You are given an integer array nums and an integer k.

easy

Minimum Number of Operations to Convert Time

You are given two strings current and correct representing two 24-hour times.

medium

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.

medium

Count the Number of Square-Free Subsets

You are given a positive integer 0-indexed array nums.

hard

Selling Pieces of Wood

You are given two integers m and n that represent the height and width of a rectangular piece of wood.

medium

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.

easy

Smallest Number With All Set Bits

You are given a positive number n.

hard

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...

medium

Find K Pairs with Smallest Sums

You are given two integer arrays nums1 and nums2 sorted in non-decreasing order and an integer k.

hard

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.

medium

Find the Maximum Length of Valid Subsequence II

A subsequence sub of nums with length x is called valid if it satisfies:

medium

Split Array by Prime Indices

You are given an integer array nums.

easy

Check If N and Its Double Exist

Given an array arr of integers, check if there exist two indices i and j such that :

medium

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.

hard

Lexicographically Smallest Beautiful String

A string is beautiful if: You are given a beautiful string s of length n and a positive integer k.

medium

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...

medium

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...

medium

Maximum Median Sum of Subsequences of Size 3

You are given an integer array nums with a length divisible by 3.

easy

Faulty Keyboard

Your laptop keyboard is faulty, and whenever you type a character 'i' on it, it reverses the string that you have written.

hard

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,...

hard

Minimize the Total Price of the Trips

There exists an undirected and unrooted tree with n nodes indexed from 0 to n - 1.

medium

Minimum Number of Steps to Make Two Strings Anagram II

You are given two strings s and t.

medium

Unique Paths II

You are given an m x n integer array grid.

medium

Count Cells in Overlapping Horizontal and Vertical Substrings

You are given an m x n matrix grid consisting of characters and a string pattern.

hard

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.

hard

Shortest Distance After Road Addition Queries II

You are given an integer n and a 2D integer array queries.

medium

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.

easy

Valid Palindrome II

Given a string s, return true if the s can be palindrome after deleting at most one character from it.

medium

Custom Sort String

You are given two strings order and s.

medium

Print Words Vertically

Given a string s.

hard

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.

easy

Uncommon Words from Two Sentences

A sentence is a string of single-space separated words where each word consists only of lowercase letters.

hard

Maximum Score Of Spliced Array

You are given two 0-indexed integer arrays nums1 and nums2, both of length n.

hard

Sliding Window Median

The median is the middle value in an ordered integer list.

easy

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.

easy

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.

medium

Decrease Elements To Make Array Zigzag

Given an array nums of integers, a move consists of choosing any element and decreasing it by 1.

hard

Network Recovery Pathways

You are given a directed acyclic graph of n nodes numbered from 0 to n − 1.

easy

Minimum Operations to Make Array Sum Divisible by K

You are given an integer array nums and an integer k.

medium

Find the N-th Value After K Seconds

You are given two integers n and k.

easy

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'.

easy

Toeplitz Matrix

Given an m x n matrix, return true if the matrix is Toeplitz.

hard

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.

easy

Intersection of Two Arrays

Given two integer arrays nums1 and nums2, return an array of their intersection.

medium

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...

medium

Mice and Cheese

There are two mice and n different types of cheese, each type of cheese should be eaten by exactly one mouse.

hard

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.

medium

Maximum Candies Allocated to K Children

You are given a 0-indexed integer array candies.

hard

Making A Large Island

You are given an n x n binary matrix grid.

medium

Minimum Operations to Make Array Equal II

You are given two integer arrays nums1 and nums2 of equal length n and an integer k.

easy

Number of Steps to Reduce a Number to Zero

Given an integer num, return the number of steps to reduce it to zero.

hard

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.

hard

Maximum Element-Sum of a Complete Subset of Indices

You are given a 1-indexed array nums.

easy

Find Champion I

There are n teams numbered from 0 to n - 1 in a tournament.

easy

Account Balance After Rounded Purchase

Initially, you have a bank account balance of 100 dollars.

medium

Find Missing Observations

You have observations of n + m 6-sided dice rolls with each face numbered from 1 to 6.

medium

Construct the Minimum Bitwise Array II

You are given an array nums consisting of n prime integers.

medium

Ambiguous Coordinates

We had some 2-dimensional coordinates, like "(1, 3)" or "(2, 0.5)".

easy

Matrix Diagonal Sum

Given a square matrix mat, return the sum of the matrix diagonals.

medium

Longest Consecutive Sequence

Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

medium

Find the Punishment Number of an Integer

Given a positive integer n, return the punishment number of n.

medium

Maximum Points in an Archery Competition

Alice and Bob are opponents in an archery competition.

easy

Merge Similar Items

You are given two 2D integer arrays, items1 and items2, representing two sets of items.

hard

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.

hard

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.

easy

Sum of All Odd Length Subarrays

Given an array of positive integers arr, return the sum of all possible odd-length subarrays of arr.

easy

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.

medium

Palindrome Partitioning

Given a string s, partition s such that every substring of the partition is a palindrome.

easy

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.

hard

Minimum Cost to Make at Least One Valid Path in a Grid

Given an m x n grid.

hard

Find All Possible Stable Binary Arrays II

You are given 3 positive integers zero, one, and limit.

medium

Basic Calculator II

Given a string s which represents an expression, evaluate this expression and return its value.

easy

Number of Segments in a String

Given a string s, return the number of segments in the string.

medium

Maximum Palindromes After Operations

You are given a 0-indexed string array words having length n and containing 0-indexed strings.

medium

Minimum Impossible OR

You are given a 0-indexed integer array nums.

hard

Closest Room

There is a hotel with n rooms.

medium

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.

easy

Reformat Date

Given a date string in the form Day Month Year, where: Convert the date string to the format YYYY-MM-DD, where:

hard

Count Special Integers

We call a positive integer special if all of its digits are distinct.

hard

Maximum Building Height

You want to build n new buildings in a city.

medium

Lexicographically Smallest String After Operations With Constraint

You are given a string s and an integer k.

medium

Single Number II

Given an integer array nums where every element appears three times except for one, which appears exactly once.

easy

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.

hard

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.

easy

Flipping an Image

Given an n x n binary matrix image, flip the image horizontally, then invert it, and return the resulting image.

medium

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.

medium

Number of Provinces

There are n cities.

medium

Find the Prefix Common Array of Two Arrays

You are given two 0-indexed integer permutations A and B of length n.

medium

Check if a Parentheses String Can Be Valid

A parentheses string is a non-empty string consisting only of '(' and ')'.

easy

Maximum Nesting Depth of the Parentheses

Given a valid parentheses string s, return the nesting depth of s.

medium

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.

medium

Matchsticks to Square

You are given an integer array matchsticks where matchsticks[i] is the length of the ith matchstick.

easy

Palindrome Number

Given an integer x, return true if x is a palindrome, and false otherwise.

medium

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.

medium

Count Prime-Gap Balanced Subarrays

You are given an integer array nums and an integer k.

medium

New 21 Game

Alice plays the following game, loosely based on the card game "21".

easy

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.

medium

Network Delay Time

You are given a network of n nodes, labeled from 1 to n.

medium

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,...

medium

Longest Subarray With Maximum Bitwise AND

You are given an integer array nums of size n.

easy

Trionic Array I

You are given an integer array nums of length n.

hard

Integer to English Words

Convert a non-negative integer num to its English words representation.

medium

Maximum Length of Repeated Subarray

Given two integer arrays nums1 and nums2, return the maximum length of a subarray that appears in both arrays.

easy

Binary Tree Paths

Return every root-to-leaf path in a binary tree as an arrow-joined string.

hard

Abbreviating the Product of a Range

You are given two positive integers left and right with left <= right.

easy

Odd String Difference

You are given an array of equal-length strings words.

medium

Minimum Time to Revert Word to Initial State I

You are given a 0-indexed string word and an integer k.

medium

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.

easy

Monotonic Array

An array is monotonic if it is either monotone increasing or monotone decreasing.

hard

Create Maximum Number

You are given two integer arrays nums1 and nums2 of lengths m and n respectively.

medium

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.

medium

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).

medium

Kth Smallest Element in a BST

Find the k-th smallest value stored in a binary search tree.

hard

Greatest Common Divisor Traversal

You are given a 0-indexed integer array nums, and you are allowed to traverse between its indices.

medium

Maximum Number of Integers to Choose From a Range I

You are given an integer array banned and two integers n and maxSum.

medium

Minimum Jumps to Reach End via Prime Teleportation

You are given an integer array nums of length n.

easy

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.

medium

Maximum Number of Alloys

You are the owner of a company that creates alloys using various types of metals.

easy

Count Largest Group

You are given an integer n.

hard

Total Appeal of A String

The appeal of a string is the number of distinct characters found in the string.

medium

Maximum Frequency After Subarray Operation

You are given an array nums of length n.

medium

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.

hard

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.

medium

Remove Comments

Given a C++ program, remove comments from it.

hard

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.

easy

Defuse the Bomb

You have a bomb to defuse, and your time is running out!

medium

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.

hard

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].

hard

Number of Distinct Roll Sequences

You are given an integer n.

medium

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.

medium

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.

easy

Minimum Deletions for At Most K Distinct Characters

You are given a string s consisting of lowercase English letters, and an integer k.

easy

Find the Pivot Integer

Given a positive integer n, find the pivot integer x such that: Return the pivot integer x.

hard

Smallest Rotation with Highest Score

You are given an array nums.

easy

A Number After a Double Reversal

Reversing an integer means to reverse all its digits.

medium

Rotate Array

Given an integer array nums, rotate the array to the right by k steps, where k is non-negative.

easy

Maximum Difference Between Even and Odd Frequency I

You are given a string s consisting of lowercase English letters.

medium

Shortest Subarray With OR at Least K II

You are given an array nums of non-negative integers and an integer k.

medium

Rotate a Linked List

Rotate a singly-linked list to the right by k places, wrapping around as needed.

easy

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.

easy

Transpose Matrix

Given a 2D integer array matrix, return the transpose of matrix.

medium

Find the Student that Will Replace the Chalk

There are n students in a class numbered from 0 to n - 1.

hard

Find a Good Subset of the Matrix

You are given a 0-indexed m x n binary matrix grid.

medium

Count Islands With Total Value Divisible by K

You are given an m x n matrix grid and a positive integer k.

easy

Number of Changing Keys

You are given a 0-indexed string s typed by a user.

hard

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...

medium

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].

medium

Maximum Product Subarray

Given an integer array nums, find a subarray that has the largest product, and return the product.

easy

Buy Two Chocolates

You are given an integer array prices representing the prices of various chocolates in a store.

medium

Subdomain Visit Count

A website domain "discuss.example.com" consists of various subdomains.

easy

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.

easy

Fair Candy Swap

Alice and Bob have a different total number of candies.

medium

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.

medium

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.

hard

Smallest Palindromic Rearrangement II

You are given a palindromic string s and an integer k.

easy

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.

easy

Unique Email Addresses

Every valid email consists of a local name and a domain name, separated by the '@' sign.

hard

Zuma Game

You are playing a variation of the game Zuma.

hard

Contain Virus

A virus is spreading rapidly, and your task is to quarantine the infected area by installing walls.

medium

Find the Count of Numbers Which Are Not Special

You are given 2 positive integers l and r.

medium

Minimum Number of Operations to Satisfy Conditions

You are given a 2D matrix grid of size m x n.

medium

Valid Parenthesis String

Given a string s containing only three types of characters: '(', ')' and '*', return true if s is valid.

medium

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...

medium

Find Longest Special Substring That Occurs Thrice I

You are given a string s that consists of lowercase English letters.

medium

Continuous Subarrays

You are given a 0-indexed integer array nums.

hard

Process String with Special Operations II

You are given a string s consisting of lowercase English letters and the special characters: '*', '#', and '%'.

easy

Number of Days Between Two Dates

Write a program to count the number of days between two dates.

hard

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.

hard

Count Prefix and Suffix Pairs II

You are given a 0-indexed string array words.

hard

Maximum Path Quality of a Graph

There is an undirected graph with n nodes numbered from 0 to n - 1 (inclusive).

medium

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.

hard

Number of Squareful Arrays

An array is squareful if the sum of every pair of adjacent elements is a perfect square.

hard

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.

medium

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...

hard

Maximum Number of Groups With Increasing Length

You are given a 0-indexed array usageLimits of length n.

medium

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.

medium

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).

hard

Concatenated Divisibility

You are given an array of positive integers nums and a positive integer k.

medium

Find the Power of K-Size Subarrays I

You are given an array of integers nums of length n and a positive integer k.

easy

Power of Three

Given an integer n, return true if it is a power of three.

hard

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.

medium

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.

medium

Capacity To Ship Packages Within D Days

A conveyor belt has packages that must be shipped from one port to another within days days.

hard

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.

hard

Smallest Missing Genetic Value in Each Subtree

There is a family tree rooted at 0 consisting of n nodes numbered 0 to n - 1.

hard

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.,...

medium

Sum of Distances

You are given a 0-indexed integer array nums.

medium

Maximum Erasure Value

You are given an array of positive integers nums and want to erase a subarray containing unique elements.

easy

Maximum Product Difference Between Two Pairs

The product difference between two pairs (a, b) and (c, d) is defined as (a * b) - (c * d).

hard

Minimum Number of Operations to Make Arrays Similar

You are given two positive integer arrays nums and target, of the same length.

medium

Minimum Remove to Make Valid Parentheses

Given a string s of '(' , ')' and lowercase English characters.

medium

Combinations

Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n].

easy

Remove Digit From Number to Maximize Result

You are given a string number representing a positive integer and a character digit.

medium

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.

medium

Number of Wonderful Substrings

A wonderful string is a string where at most one letter appears an odd number of times.

hard

Delivering Boxes from Storage to Ports

You have the task of delivering some boxes from storage to their ports using only one ship.

hard

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.

medium

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.

easy

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.

hard

Maximum Running Time of N Computers

You have n computers.

easy

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).

hard

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.

medium

All Divisions With the Highest Score of a Binary Array

You are given a 0-indexed binary array nums of length n.

medium

Removing Minimum and Maximum From Array

You are given a 0-indexed array of distinct integers nums.

medium

Minimum Absolute Difference in Sliding Submatrix

You are given an m x n integer matrix grid and an integer k.

medium

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].

hard

Longest Duplicate Substring

Given a string s, consider all duplicated substrings: (contiguous) substrings of s that occur 2 or more times.

medium

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, ...].

medium

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.

easy

Find Minimum Log Transportation Cost

You are given integers n, m, and k.

medium

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...

medium

Construct String With Repeat Limit

You are given a string s and an integer repeatLimit.

medium

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.

hard

Chalkboard XOR Game

You are given an array of integers nums represents the numbers written on a chalkboard.

medium

Maximum Difference Score in a Grid

You are given an m x n matrix grid consisting of positive integers.

medium

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.

medium

Sum of Subarray Ranges

You are given an integer array nums.

medium

Minimum Sum of Mountain Triplets II

You are given a 0-indexed array nums of integers.

medium

Prison Cells After N Days

There are 8 prison cells in a row and each cell is either occupied or vacant.

easy

Word Pattern

Given a pattern and a string s, find if s follows the same pattern.

medium

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.

medium

Expressive Words

Sometimes people repeat letters to represent extra feeling.

medium

Check If Array Pairs Are Divisible by k

Given an array of integers arr of even length n and an integer k.

hard

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...

medium

Top K Frequent Words

Given an array of strings words and an integer k, return the k most frequent strings.

medium

Fill a Special Grid

You are given a non-negative integer n representing a 2n x 2n grid.

medium

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...

medium

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.

medium

Count Complete Subarrays in an Array

You are given an array nums consisting of positive integers.

hard

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.

easy

Power of Two

Given an integer n, return true if it is a power of two.

easy

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...

hard

Odd Even Jump

You are given an integer array arr.

medium

Assign Elements to Groups with Constraints

You are given an integer array groups, where groups[i] represents the size of the ith group.

hard

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.

medium

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.

hard

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.

medium

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.

hard

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.

medium

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...

medium

Clumsy Factorial

The factorial of a positive integer n is the product of all positive integers less than or equal to n.

easy

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.

medium

Find All Possible Recipes from Given Supplies

You have information about n different recipes.

hard

Find the Minimum Cost Array Permutation

You are given an array nums which is a permutation of [0, 1, 2, ..., n - 1].

easy

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.

easy

Remove Linked List Elements

Delete every node in a singly-linked list whose value matches a given target.

hard

Create Sorted Array through Instructions

Given an integer array instructions, you are asked to create a sorted array from the elements in instructions.

medium

Robot Bounded In Circle

On an infinite plane, a robot initially stands at (0, 0) and faces north.

medium

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...

hard

Erect the Fence

You are given an array trees where trees[i] = [xi, yi] represents the location of a tree in the garden.

hard

Course Schedule III

There are n different online courses numbered from 1 to n.

easy

Minimum Operations to Make Array Values Equal to K

You are given an integer array nums and an integer k.

hard

Robot Collisions

There are n 1-indexed robots, each having a position on a line, health, and movement direction.

easy

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.

easy

Maximum Ascending Subarray Sum

Given an array of positive integers nums, return the maximum possible sum of an strictly increasing subarray in nums.

easy

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.

medium

Split Two Strings to Make Palindrome

You are given two strings a and b of the same length.

easy

Reverse Only Letters

Given a string s, reverse the string according to the following rules: Return s after reversing it.

easy

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.

hard

Minimum Cost to Cut a Stick

Given a wooden stick of length n units.

easy

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.

easy

Count Elements With Maximum Frequency

You are given an array nums consisting of positive integers.

medium

Minimum Operations to Halve Array Sum

You are given an array nums of positive integers.

easy

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.

medium

Find the Lexicographically Largest String From the Box I

You are given a string word, and an integer numFriends.

medium

Find the Minimum Possible Sum of a Beautiful Array

You are given positive integers n and target.

medium

Longest Square Streak in an Array

You are given an integer array nums.

medium

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.

medium

Count the Number of Computer Unlocking Permutations

You are given an array complexity of length n.

medium

Jump Game III

Given an array of non-negative integers arr, you are initially positioned at start index of the array.

easy

Min Max Game

You are given a 0-indexed integer array nums whose length is a power of 2.

medium

Find And Replace in String

You are given a 0-indexed string s that you must perform k replacement operations on.

medium

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.

medium

Advantage Shuffle

You are given two integer arrays nums1 and nums2 both of the same length.

hard

Jump Game V

Given an array of integers arr and an integer d.

medium

Minimum Number of Days to Make m Bouquets

You are given an integer array bloomDay, an integer m and an integer k.

medium

Next Permutation

A permutation of an array of integers is an arrangement of its members into a sequence or linear order.

easy

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.

easy

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.

medium

UTF-8 Validation

Given an integer array data representing the data, return whether it is a valid UTF-8 encoding (i.e.

easy

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.

medium

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.

hard

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.

hard

Count the Number of Ideal Arrays

You are given two integers n and maxValue, which are used to describe an ideal array.

hard

Minimum Time to Complete All Tasks

There is a computer that can run an unlimited number of tasks at the same time.

easy

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.

hard

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.

medium

Decode XORed Permutation

There is an integer array perm that is a permutation of the first n positive integers, where n is always odd.

medium

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].

medium

Design a URL Shortener

Design a scalable short link service.

hard

Find the Longest Valid Obstacle Course at Each Position

You want to build some obstacle courses.

hard

Find All Good Strings

Given the strings s1 and s2 of size n and the string evil, return the number of good strings.

easy

Symmetric Tree

Determine whether a binary tree is a mirror of itself around its center.

hard

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:

medium

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.

hard

Sum of Prefix Scores of Strings

You are given an array words of size n consisting of non-empty strings.

easy

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.

medium

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).

hard

Maximum Segment Sum After Removals

You are given two 0-indexed integer arrays nums and removeQueries, both of length n.

medium

Largest Element in an Array after Merge Operations

You are given a 0-indexed array nums consisting of positive integers.

easy

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.

medium

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.

easy

Find the Array Concatenation Value

You are given a 0-indexed integer array nums.

hard

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).

hard

Maximum Total Reward Using Operations II

You are given an integer array rewardValues of length n, representing the values of rewards.

easy

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.

easy

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.

medium

Beautiful Array

An array nums of length n is beautiful if: Given the integer n, return any beautiful array nums of length n.

easy

Stone Removal Game

Alice and Bob are playing a game where they take turns removing stones from a pile, with Alice going first.

hard

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.

medium

Group Anagrams

Given an array of strings strs, group the anagrams together.

hard

Number of Ways to Rearrange Sticks With K Sticks Visible

There are n uniquely-sized sticks whose lengths are integers from 1 to n.

medium

Check if There is a Valid Path in a Grid

You are given an m x n grid.

medium

Minimum Average Difference

You are given a 0-indexed integer array nums of length n.

easy

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.

hard

Max Chunks To Make Sorted II

You are given an integer array arr.

hard

Consecutive Numbers Sum

Given an integer n, return the number of ways you can write n as the sum of consecutive positive integers.

medium

Minimum Array End

You are given two integers n and x.

medium

Most Popular Video Creator

You are given two string arrays creators and ids, and an integer array views, all of length n.

hard

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.

easy

Most Frequent Number Following Key In an Array

You are given a 0-indexed integer array nums.

easy

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.

medium

Best Sightseeing Pair

You are given an integer array values where values[i] represents the value of the ith sightseeing spot.

hard

Kth Smallest Instructions

Bob is standing at cell (0, 0), and he wants to reach destination: (row, column).

medium

Brick Wall

There is a rectangular brick wall in front of you with n rows of bricks.

medium

Course Schedule II

There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1.

hard

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.

easy

Most Visited Sector in a Circular Track

Given an integer n and an integer array rounds.

easy

Find Words Containing Character

You are given a 0-indexed array of strings words and a character x.

medium

Find All Lonely Numbers in the Array

You are given an integer array nums.

hard

Parallel Courses III

You are given an integer n, which indicates that there are n courses labeled from 1 to n.

easy

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.

medium

Predict the Winner

You are given an integer array nums.

hard

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...

hard

Partition Array for Maximum XOR and AND

You are given an integer array nums.

medium

Evaluate Reverse Polish Notation

You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation.

easy

Delete Columns to Make Sorted

You are given an array of n strings strs, all of the same length.

medium

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.

medium

Minimum Number of Work Sessions to Finish the Tasks

There are n tasks assigned to you.

medium

Permutation in String

Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise.

medium

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 '+').

easy

Special Array I

An array is considered special if the parity of every pair of adjacent elements is different.

medium

Number of Ways to Split Array

You are given a 0-indexed integer array nums of length n.

hard

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.

medium

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...

medium

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.

medium

Minimum Adjacent Swaps to Reach the Kth Smallest Number

You are given a string num, representing a large integer, and an integer k.

medium

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.

medium

Shortest String That Contains Three Strings

If there are multiple such strings, return the lexicographically smallest one.

medium

Factorial Trailing Zeroes

Given an integer n, return the number of trailing zeroes in n!.

easy

Construct the Minimum Bitwise Array I

You are given an array nums consisting of n prime integers.

easy

Count the Number of Incremovable Subarrays I

You are given a 0-indexed array of positive integers nums.

medium

Koko Eating Bananas

Koko loves to eat bananas.

hard

Maximum Number of Ways to Partition an Array

You are given a 0-indexed integer array nums of length n.

hard

Groups of Strings

You are given a 0-indexed array of strings words.

easy

Maximum Containers on a Ship

You are given a positive integer n representing an n x n cargo deck on a ship.

hard

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...

medium

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.

easy

Arranging Coins

You have n coins and you want to build a staircase with these coins.

hard

Next Greater Element IV

You are given a 0-indexed array of non-negative integers nums.

medium

Minimum Suffix Flips

You are given a 0-indexed binary string target of length n.

easy

Matrix Cells in Distance Order

You are given four integers row, cols, rCenter, and cCenter.

easy

Minimum Sum of Four Digit Number After Splitting Digits

You are given a positive integer num consisting of exactly four digits.

easy

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.

medium

Detonate the Maximum Bombs

You are given a list of bombs.

easy

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...

easy

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.

hard

Longest Path With Different Adjacent Characters

You are given a tree (i.e.

medium

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...

medium

Path In Zigzag Labelled Binary Tree

In an infinite binary tree where every node has two children, the nodes are labelled in row order.

hard

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...

easy

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...

hard

Shortest Impossible Sequence of Rolls

You are given an integer array rolls of length n and an integer k.

medium

Max Difference You Can Get From Changing an Integer

You are given an integer num.

easy

Count Operations to Obtain Zero

You are given two non-negative integers num1 and num2.

medium

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.

medium

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...

easy

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...

hard

Smallest Substring With Identical Characters II

You are given a binary string s of length n and an integer numOps.

hard

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.

hard

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...

easy

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.

medium

Find Latest Group of Size M

Given an array arr that represents a permutation of numbers from 1 to n.

easy

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).

easy

The Employee That Worked on the Longest Task

There are n employees, each with a unique id from 0 to n - 1.

medium

Longest Non-decreasing Subarray From Two Arrays

You are given two 0-indexed integer arrays nums1 and nums2 of length n.

medium

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.

easy

Robot Return to Origin

There is a robot starting at the position (0, 0), the origin, on a 2D plane.

medium

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.

medium

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.

medium

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...

medium

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……".

medium

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.

hard

Verbal Arithmetic Puzzle

Given an equation, represented by words on the left side and the result on the right side.

hard

Minimum Incompatibility

You are given an integer array nums​​​ and an integer k.

medium

Longest Substring Without Repeating Characters

Given a string s, find the length of the longest substring without duplicate characters.

medium

Minimum Jumps to Reach Home

A certain bug's home is on the x-axis at position x.

medium

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.

easy

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.

medium

Eat Pizzas!

You are given an integer array pizzas of size n, where pizzas[i] represents the weight of the ith pizza.

easy

Goat Latin

You are given a string sentence that consist of words separated by spaces.

medium

Stone Game II

Alice and Bob continue their games with piles of stones.

medium

Maximum Value at a Given Index in a Bounded Array

You are given three positive integers: n, index, and maxSum.

medium

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.

medium

Reverse Substrings Between Each Pair of Parentheses

You are given a string s that consists of lower case English letters and brackets.

medium

Count Covered Buildings

You are given a positive integer n, representing an n x n city.

medium

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.

hard

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.

easy

Furthest Point From Origin

You are given a string moves of length n consisting only of characters 'L', 'R', and '_'.

medium

Maximum Total Reward Using Operations I

You are given an integer array rewardValues of length n, representing the values of rewards.

medium

Identify the Largest Outlier in an Array

You are given an integer array nums.

medium

Reorganize String

Given a string s, rearrange the characters of s so that any two adjacent characters are not the same.

medium

Count Partitions With Max-Min Difference at Most K

You are given an integer array nums and an integer k.

easy

Largest Odd Number in String

You are given a string num, representing a large integer.

easy

Best Poker Hand

You are given an integer array ranks and a character array suits.

medium

Moving Stones Until Consecutive

There are three stones in different positions on the X-axis.

medium

Find the Minimum Area to Cover All Ones I

You are given a 2D binary array grid.

hard

Find the K-Sum of an Array

You are given an integer array nums and a positive integer k.

medium

Moving Stones Until Consecutive II

There are some stones in different positions on the X-axis.

medium

Lexicographical Numbers

Given an integer n, return all the numbers in the range [1, n] sorted in lexicographical order.

easy

Maximum Repeating Substring

For a string sequence, a string word is k-repeating if word concatenated k times is a substring of sequence.

medium

Minimum Consecutive Cards to Pick Up

You are given an integer array cards where cards[i] represents the value of the ith card.

hard

Stone Game VIII

Alice and Bob take turns playing a game, with Alice starting first.

hard

24 Game

You are given an integer array cards of length 4.

easy

Decrypt String from Alphabet to Integer Mapping

You are given a string s formed by digits and '#'.

hard

Burst Balloons

You are given n balloons, indexed from 0 to n - 1.

hard

Count Substrings That Can Be Rearranged to Contain a String II

You are given two strings word1 and word2.

medium

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).

easy

Generate Tag for Video Caption

You are given a string caption representing the caption for a video.

hard

The Earliest and Latest Rounds Where Players Compete

There is a tournament where n players are participating.

easy

Modify the Matrix

Given a 0-indexed m x n integer matrix matrix, create a new 0-indexed matrix called answer.

medium

Maximum Earnings From Taxi

There are n points on a road you are driving your taxi on.

medium

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...

medium

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.

medium

Minimum Sideway Jumps

There is a 3 lane road of length n that consists of n + 1 points labeled from 0 to n.

hard

Maximum Candies You Can Get from Boxes

You have n boxes labeled from 0 to n - 1.

medium

Partition Array into Two Equal Product Subsets

You are given an integer array nums containing distinct positive integers and an integer target.

easy

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.

medium

Longest Absolute File Path

Suppose we have a file system that stores both files and directories.

easy

Shift 2D Grid

Given a 2D grid of size m x n and an integer k.

medium

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.

hard

Count Subarrays With Fixed Bounds

You are given an integer array nums and two integers minK and maxK.

medium

Diagonal Traverse II

Given a 2D integer array nums, return all elements of nums in diagonal order as shown in the below images.

hard

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.

hard

Split Message Based on Limit

You are given a string, message, and a positive integer, limit.

easy

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.

hard

Find the Original Typed String II

Alice is attempting to type a specific string on her computer.

medium

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.

easy

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.

medium

Sum of K Subarrays With Length at Least M

You are given an integer array nums and two integers, k and m.

medium

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.

hard

Minimize Deviation in Array

You are given an array nums of n positive integers.

easy

Find the K-th Character in String Game I

Alice and Bob are playing a game.

hard

Block Placement Queries

There exists an infinite number line, with its origin at 0 and extending towards the positive x-axis.

hard

Maximum Genetic Difference Query

There is a rooted tree consisting of n nodes numbered 0 to n - 1.

hard

Sum of Subsequence Widths

The width of a sequence is the difference between the maximum and minimum elements in the sequence.

hard

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.

easy

Happy Number

Write an algorithm to determine if a number n is happy.

medium

Find Two Non-overlapping Sub-arrays Each With Target Sum

You are given an array of integers arr and an integer target.

hard

Maximum Score of a Node Sequence

There is an undirected graph with n nodes, numbered from 0 to n - 1.

medium

Maximum Absolute Sum of Any Subarray

You are given an integer array nums.

hard

Count Beautiful Numbers

You are given two positive integers, l and r.

easy

Check If Digits Are Equal in String After Operations I

You are given a string s consisting of digits.

hard

Count Non-Decreasing Subarrays After K Operations

You are given an array nums of n integers and an integer k.

easy

Longest Unequal Adjacent Groups Subsequence I

You are given a string array words and a binary array groups both of length n.

easy

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.

easy

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.

medium

Count Special Triplets

You are given an integer array nums.

medium

Maximum Gap

Given an integer array nums, return the maximum difference between two successive elements in its sorted form.

hard

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].

medium

Minimum Moves to Capture The Queen

There is a 1-indexed 8 x 8 chessboard containing 3 pieces.

medium

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.

medium

Minimum Length of String After Operations

You are given a string s.

easy

Minimum Operations to Exceed Threshold Value I

You are given a 0-indexed integer array nums, and an integer k.

easy

Divisor Game

Alice and Bob take turns playing a game, with Alice starting first.

medium

Minimum Number of Operations to Make X and Y Equal

You are given two positive integers x and y.

medium

Redundant Connection

In this problem, a tree is an undirected graph that is connected and has no cycles.

medium

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.

hard

Find a Value of a Mysterious Function Closest to Target

Winston was given the above mysterious function func.

easy

Maximum Number of Pairs in Array

You are given a 0-indexed integer array nums.

easy

Count Distinct Numbers on Board

You are given a positive integer n, that is initially placed on a board.

hard

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:...

easy

Minimum Common Value

Given two integer arrays nums1 and nums2, sorted in non-decreasing order, return the minimum integer common to both arrays.

medium

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.

hard

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,...

medium

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.

medium

Stone Game VII

Alice and Bob take turns playing a game, with Alice starting first.

hard

Count Number of Possible Root Nodes

Alice has an undirected tree with n nodes labeled from 0 to n - 1.

medium

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.

medium

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...

easy

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...

medium

Maximum Multiplication Score

You are given an integer array a of size 4 and another integer array b of size at least 4.

hard

Count Subarrays With Score Less Than K

The score of an array is defined as the product of its sum and its length.

medium

Minimized Maximum of Products Distributed to Any Store

You are given an integer n indicating there are n specialty retail stores.

hard

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.

easy

Roman to Integer

Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.

medium

Possible Bipartition

We want to split a group of n people (labeled from 1 to n) into two groups of any size.

medium

Change Minimum Characters to Satisfy One of Three Conditions

You are given two strings a and b that consist of lowercase letters.

medium

Minimum Swaps to Make Strings Equal

You are given two strings s1 and s2 of equal length consisting of letters "x" and "y" only.

medium

Check If Word Is Valid After Substitutions

Given a string s, determine if it is valid.

medium

Guess Number Higher or Lower II

We are playing the Guessing Game.

medium

Count Nice Pairs in an Array

You are given an array nums that consists of non-negative integers.

medium

Bulls and Cows

You are playing the Bulls and Cows game with your friend.

medium

Apply Operations to Make Sum of Array Greater Than or Equal to k

You are given a positive integer k.

medium

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].

medium

Minimum Sum of Squared Difference

You are given two positive 0-indexed integer arrays nums1 and nums2, both of length n.

medium

Minimum Cost to Make Array Equalindromic

You are given a 0-indexed integer array nums having length n.

medium

Minimum Number of Operations to Make All Array Elements Equal to 1

You are given a 0-indexed array nums consisiting of positive integers.

hard

Maximize the Number of Partitions After Operations

You are given a string s and an integer k.

medium

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...

hard

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...

medium

Maximum Sum Obtained of Any Permutation

We have an array of integers, nums, and an array of requests where requests[i] = [starti, endi].

easy

Left and Right Sum Differences

You are given a 0-indexed integer array nums of size n.

hard

Maximum Good Subtree Score

You are given an undirected tree rooted at node 0 with n nodes numbered from 0 to n - 1.

medium

Reach End of Array With Max Score

You are given an integer array nums of length n.

hard

Kth Smallest Path XOR Sum

You are given an undirected tree rooted at node 0 with n nodes numbered from 0 to n - 1.

hard

Maximize Subarray GCD Score

You are given an array of positive integers nums and an integer k.

medium

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...

medium

Longest Uncommon Subsequence II

Given an array of strings strs, return the length of the longest uncommon subsequence between them.

medium

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.

medium

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...

hard

Divide Nodes Into the Maximum Number of Groups

You are given a positive integer n representing the number of nodes in an undirected graph.

easy

Convert the Temperature

You are given a non-negative floating point number rounded to two decimal places celsius, that denotes the temperature in Celsius.

medium

Longest Binary Subsequence Less Than or Equal to K

You are given a binary string s and a positive integer k.

medium

Score After Flipping Matrix

You are given an m x n binary matrix grid.

medium

Count the Number of Complete Components

You are given an integer n.

easy

Check Divisibility by Digit Sum and Product

You are given a positive integer n.

hard

Valid Number

Given a string s, return whether s is a valid number.

medium

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.

hard

Threshold Majority Queries

You are given an integer array nums of length n and an array queries, where queries[i] = [li, ri, thresholdi].

medium

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.

hard

Palindrome Pairs

You are given a 0-indexed array of unique strings words.

easy

Two Furthest Houses With Different Colors

There are n houses evenly lined up on the street, and each house is beautifully painted.

hard

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.

hard

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.

hard

Build Array Where You Can Find The Maximum Exactly K Comparisons

You are given three integers n, m and k.

easy

Shuffle String

You are given a string s and an integer array indices of the same length.

medium

Wiggle Subsequence

A wiggle sequence is a sequence where the differences between successive numbers strictly alternate between positive and negative.

medium

Maximum Number of Subsequences After One Inserting

You are given a string s consisting of uppercase English letters.

easy

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.

easy

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.

medium

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.

hard

Number of Ways to Divide a Long Corridor

Along a long library corridor, there is a line of seats and decorative plants.

hard

Find the Sum of Subsequence Powers

You are given an integer array nums of length n, and a positive integer k.

medium

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:

medium

Removing Stars From a String

You are given a string s, which contains stars *.

medium

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].

hard

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.

hard

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.

easy

Find Special Substring of Length K

You are given a string s and an integer k.

easy

Sign of the Product of an Array

Implement a function signFunc(x) that returns: You are given an integer array nums.

easy

Backspace String Compare

Given two strings s and t, return true if they are equal when both are typed into empty text editors.

easy

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.

medium

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.

medium

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.

hard

Rearranging Fruits

You have two fruit baskets containing n fruits each.

easy

Find All K-Distant Indices in an Array

You are given a 0-indexed integer array nums and two integers key and k.

medium

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].

easy

Relative Sort Array

Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1.

medium

Sort an Array

Given an array of integers nums, sort the array in ascending order and return it.

easy

Score of a String

You are given a string s.

medium

Maximum Points Tourist Can Earn

You are given two integers, n and k, along with two 2D integer arrays, stayScore and travelScore.

medium

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.

hard

Make the XOR of All Segments Equal to Zero

You are given an array nums​​​ and an integer k​​​​​.

hard

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.

medium

Split Array into Consecutive Subsequences

You are given an integer array nums that is sorted in non-decreasing order.

easy

First Letter to Appear Twice

Given a string s consisting of lowercase English letters, return the first letter to appear twice.

medium

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.

hard

Find the Count of Monotonic Pairs I

You are given an array of positive integers nums of length n.

hard

Count Ways to Make Array With Product

You are given a 2D integer array, queries.

hard

Maximum XOR With an Element From Array

You are given an array nums consisting of non-negative integers.

hard

Stamping the Grid

You are given an m x n binary matrix grid where each cell is either 0 (empty) or 1 (occupied).

hard

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...

easy

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...

hard

Minimum Obstacle Removal to Reach Corner

You are given a 0-indexed 2D integer array grid of size m x n.

easy

Valid Anagram

Given two strings s and t, return true if t is an anagram of s, and false otherwise.

easy

Kth Missing Positive Number

Given an array arr of positive integers sorted in a strictly increasing order, and an integer k.

hard

Minimum Space Wasted From Packaging

You have n packages that you are trying to place in boxes, one package in each box.

medium

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].

medium

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.

hard

Kth Smallest Amount With Single Denomination Combination

You are given an integer array coins representing coins of different denominations and an integer k.

medium

Collecting Chocolates

You are given a 0-indexed integer array nums of size n representing the cost of collecting different chocolates.

medium

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.

medium

Minimize the Difference Between Target and Chosen Elements

You are given an m x n integer matrix mat and an integer target.

easy

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.

hard

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).

easy

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.

medium

Count Total Number of Colored Cells

There exists an infinitely large two-dimensional grid of uncolored unit cells.

hard

Minimum Adjacent Swaps for K Consecutive Ones

You are given an integer array, nums, and an integer k.

medium

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.

medium

Minimum Number of Pushes to Type Word II

You are given a string word containing lowercase English letters.

easy

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...

medium

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.

easy

Convert 1D Array Into 2D Array

You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n.

easy

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.

easy

Number of Senior Citizens

You are given a 0-indexed array of strings details.

medium

Words Within Two Edits of Dictionary

You are given two string arrays, queries and dictionary.

medium

Circular Array Loop

You are playing a game involving a circular array of non-zero integers nums.

medium

Minimum Score Triangulation of Polygon

You have a convex n-sided polygon where each vertex has an integer value.

medium

Maximum Product After K Increments

You are given an array of non-negative integers nums and an integer k.

medium

Permutations II

Given a collection of numbers, nums, that might contain duplicates, return all possible unique permutations in any order.

hard

Last Day Where You Can Still Cross

There is a 1-based binary matrix where 0 represents land and 1 represents water.

medium

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...

hard

Find the Maximum Number of Fruits Collected

There is a game dungeon comprised of n x n rooms arranged in a grid.

medium

Count Subarrays Where Max Element Appears at Least K Times

You are given an integer array nums and a positive integer k.

medium

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 '$'.

medium

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.

medium

Number of Longest Increasing Subsequence

Given an integer array nums, return the number of longest increasing subsequences.

easy

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.

medium

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.

medium

Unit Conversion I

There are n types of units indexed from 0 to n - 1.

medium

Longest Increasing Subsequence

Given an integer array nums, return the length of the longest strictly increasing subsequence.

hard

Count the Number of Good Partitions

You are given a 0-indexed array nums consisting of positive integers.

hard

Number of Pairs Satisfying Inequality

You are given two 0-indexed integer arrays nums1 and nums2, each of size n, and an integer diff.

medium

Count Number of Texts

Alice is texting Bob using her phone.

medium

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...

medium

Shortest Uncommon Substring in an Array

You are given an array arr of size n consisting of non-empty strings.

easy

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.

easy

Square Every Element In Place

Practice raw array basics: fixed-size indexing, iteration, and in-place mutation.

easy

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.

medium

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.

easy

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.

easy

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.

easy

Factorial with Recursion

Practice writing a recursive function with a clear base case and recursive case.

easy

Build a Repeated, Joined String

Practice building a string incrementally (StringBuilder/append) instead of repeated concatenation.

easy

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.

medium

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.

easy

Merge Two Sorted Linked Lists

Splice two sorted singly-linked lists together into a single sorted list.

medium

Swap Nodes in Pairs

Swap every two adjacent nodes in a singly-linked list and return the new head.

easy

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.

medium

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.

easy

Valid Parentheses

Determine if a string of brackets is properly matched and nested.

easy

Search in a Binary Search Tree

Find the node with a given value in a binary search tree and return the subtree rooted there.

easy

K-th Smallest Unique Value

Practice using a sorted set (TreeSet/SortedSet) to keep values unique and in order.

easy

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.

medium

Odd-Even Linked List

Regroup a singly-linked list so all odd-positioned nodes come before all even-positioned nodes.

easy

Two Sum

Find two numbers in an array that add up to a target value.

easy

Convert a Sorted Array to a Balanced BST

Build a height-balanced binary search tree from an array sorted in ascending order.

easy

Reverse a Linked List

Reverse a singly-linked list in place and return the reversed list.

easy

Serve the First K Customers in Line

Practice using a queue (Queue/Deque) to process items in first-in, first-out order.

easy

Range Sum of a BST

Sum every node value in a binary search tree that falls within a given inclusive range.

easy

Minimum Absolute Difference in a BST

Find the smallest absolute difference between the values of any two distinct nodes in a binary search tree.

easy

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.

easy

Middle of the Linked List

Find the value stored in the middle node of a singly-linked list in a single pass.