1697. 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...
839. Similar String Groups
Two strings X and Y are similar if we can swap two letters (in different positions) of X, so that...
319. Bulb Switcher
There are n bulbs that are initially off. You first turn on all the bulbs, then you turn off every...
258. Add Digits
Given an integer num, repeatedly add all its digits until the result has only one digit, and return it. Example...
2336. Smallest Number in Infinite Set
You have a set which contains all positive integers [1, 2, 3, 4, 5, ...]. Implement the SmallestInfiniteSet class: SmallestInfiniteSet()...
1046. Last Stone Weight
You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing...
1416. Restore The Array
A program was supposed to print an array of integers. The program forgot to print whitespaces and the array is...
1312. Minimum Insertion Steps to Make a String Palindrome
Given a string s. In one step you can insert any character at any index of the string. Return the...
879. Profitable Schemes
There is a group of n members, and a list of various crimes they could commit. The ith crime generates...
662. Maximum Width of Binary Tree
Given the root of a binary tree, return the maximum width of the given tree. The maximum width of a...
1372. Longest ZigZag Path in a Binary Tree
You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow:...
1768. Merge Strings Alternately
You are given two strings word1 and word2. Merge the strings by adding letters in alternating order, starting with word1....
1431. Kids With the Greatest Number of Candies
There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of...
1639. 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. Your task is to...
2218. Maximum Value of K Coins From Piles
There are n piles of coins on a table. Each pile consists of a positive number of coins of assorted...
516. Longest Palindromic Subsequence
Given a string s, find the longest palindromic subsequence’s length in s. A subsequence is a sequence that can be...
946. Validate Stack Sequences
Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result...
71. Simplify Path
Given a string path, which is an absolute path (starting with a slash '/') to a file or directory in...
2390. Removing Stars From a String
You are given a string s, which contains stars *. In one operation, you can: Choose a star in s....
20. Valid Parentheses
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string...
1857. Largest Color Value in a Directed Graph
There is a directed graph of n colored nodes and m edges. The nodes are numbered from 0 to n...
133. Clone Graph
Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each...
1020. Number of Enclaves
You are given an m x n binary matrix grid, where 0 represents a sea cell and 1 represents a...
1254. Number of Closed Islands
Given a 2D grid consists of 0s (land) and 1s (water). An island is a maximal 4-directionally connected group of...
2439. Minimize Maximum of Array
You are given a 0-indexed array nums comprising of n non-negative integers. In one operation, you must: Choose an integer...
2405. Optimal Partition of String
Given a string s, partition the string into one or more substrings such that the characters in each substring are...
881. 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...
2300. 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...
704. Binary Search
Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to...
1444. 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 '.'...