729. My Calendar I

Problem You are implementing a program to use as your calendar. We can add a new event if adding the event will not cause a d...

medium

985. Sum of Even Numbers After Queries

Problem You are given an integer array nums and an array queries where queries[i] = [valᵢ, indexᵢ]. For each query i, first, ...

medium

767. Reorganize String

Problem Given a string s, rearrange the characters of s so that any two adjacent characters are not the same. Return any poss...

medium

1765. Map of Highest Peak

Problem You are given an integer matrix isWater of size m x n that represents a map of land and water cells. If isWater[i][j...

medium

542. 01 Matrix

Problem Given an m x n binary matrix mat, return the distance of the nearest 0 for each cell. The distance between two cells ...

medium

1029. Two City Scheduling

Problem A company is planning to interview 2n people. Given the array costs where costs[i] = [aCostᵢ, bCostᵢ], the cost of fl...

medium

1072. Flip Columns For Maximum Number of Equal Rows

Problem You are given an m x n binary matrix matrix. You can choose any number of columns in the matrix and flip every cell i...

medium

382. Linked List Random Node

Problem Given a singly linked list, return a random node’s value from the linked list. Each node must have the same probabili...

medium

221. Maximal Square

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

medium

164. Maximum Gap

Problem Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the...

medium

983. Minimum Cost For Tickets

Problem You have planned some train traveling one year in advance. The days of the year in which you will travel are given as...

medium

2466. Count Ways To Build Good Strings

Problem Given the integers zero, one, low, and high, we can construct a string by starting with an empty string, and then at ...

medium

1367. Linked List in Binary Tree

Problem Given a binary tree root and a linked list with head as the first node. Return True if all the elements in the linked...

medium

1366. Rank Teams by Votes

Problem In a special ranking system, each voter gives a rank from highest to lowest to all teams participating in the competi...

medium

785. Is Graph Bipartite?

Problem There is an undirected graph with n nodes, where each node is numbered between 0 and n - 1. You are given a 2D array ...

medium

1014. Best Sightseeing Pair

Problem You are given an integer array values where values[i] represents the value of the iᵗʰ sightseeing spot. Two sightseei...

medium

3159. Find Occurrences of an Element in an Array

Problem You are given an integer array nums, an integer array queries, and an integer x. For each queries[i], you need to fin...

medium

494. Target Sum

Problem You are given an integer array nums and an integer target. You want to build an expression out of nums by adding one ...

medium

515. Find Largest Value in Each Tree Row

Problem Given the root of a binary tree, return an array of the largest value in each row of the tree (0-indexed). https://le...

medium

3218. Minimum Cost for Cutting Cake I

Problem There is an m x n cake that needs to be cut into 1 x 1 pieces. You are given integers m, n, and two arrays: horizont...

medium hard

1705. Maximum Number of Eaten Apples

Problem There is a special kind of apple tree that grows apples every day for n days. On the iᵗʰ day, the tree grows apples[i...

medium

721. Accounts Merge

Problem Given a list of accounts where each element accounts[i] is a list of strings, where the first element accounts[i][0] ...

medium

2471. Minimum Number of Operations to Sort a Binary Tree by Level

Problem You are given the root of a binary tree with unique values. In one operation, you can choose any two nodes at the sam...

medium

855. Exam Room

Problem There is an exam room with n seats in a single row labeled from 0 to n - 1. When a student enters the room, they must...

medium

684. Redundant Connection

Problem In this problem, a tree is an undirected graph that is connected and has no cycles. You are given a graph that starte...

medium

1387. Sort Integers by The Power Value

Problem The power of an integer x is defined as the number of steps needed to transform x into 1 using the following steps: ...

medium

95. Unique Binary Search Trees II

Problem Given an integer n, return all the structurally unique BST’s (binary search trees), which has exactly n nodes of uniq...

medium

2545. Sort the Students by Their Kth Score

Problem There is a class with m students and n exams. You are given a 0-indexed m x n integer matrix score, where each row re...

medium

96. Unique Binary Search Trees

Problem Given an integer n, return the number of structurally unique BST’s (binary search trees) which has exactly n nodes of...

medium

89. Gray Code

Problem An n-bit gray code sequence is a sequence of 2ⁿ integers where: Every integer is in the inclusive range [0, 2ⁿ - 1],...

medium

72. Edit Distance

Problem Given two strings word1 and word2, return the minimum number of operations required to convert word1 to word2. You ha...

medium

50. Pow(x, n)

Problem Implement pow(x, n), which calculates x raised to the power n (i.e., xⁿ). https://leetcode.com/problems/powx-n/ Examp...

medium