全站内容
medium
208. Implement Trie (Prefix Tree)
#Problem A trie (pronounced as “try”) or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. …
207. Course Schedule
#Problem There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [aᵢ, bᵢ] indicates that you must take course bᵢ first if you want to take …
3233. Find the Count of Numbers Which Are Not Special
#Problem You are given 2 positive integers l and r. For any number x, all positive divisors of x except x are called the proper divisors of x. A number is called special if it has exactly 2 proper divisors. For example: The number 4 is …
79. Word Search
#Problem Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically …
73. Set Matrix Zeroes
#Problem Given an m x n integer matrix matrix, if an element is 0, set its entire row and column to 0’s. You must do it in place. https://leetcode.com/problems/set-matrix-zeroes/ Example 1: case1Input: matrix = [[1,1,1],[1,0,1],[1,1,1]] …
200. Number of Islands
#Problem Given an m x n 2D binary grid grid which represents a map of '1's (land) and '0's (water), return the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You …
198. House Robber
#Problem You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent houses have security systems …
322. Coin Change
#Problem You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money. Return the fewest number of coins that you need to make up that amount. If that amount …
3243. Shortest Distance After Road Addition Queries I
#Problem You are given an integer n and a 2D integer array queries. There are n cities numbered from 0 to n - 1. Initially, there is a unidirectional road from city i to city i + 1 for all 0 <= i < n - 1. queries[i] = [uᵢ, vᵢ] represents …
62. Unique Paths
#Problem There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or …