原文链接: https://leetcode-cn.com/problems/same-tree 英文原文Given the roots of two binary trees p and q, write a function to check if they are the same or not. Two binary trees are considered the same if they are structurally identical, and the nodes have t…
标签详情
广度优先搜索 分类
原文链接: https://leetcode-cn.com/problems/symmetric-tree 英文原文Given the root of a binary tree, check whether it is a mirror of itself (i.e., symmetric around its center). Example 1: Input: root = [1,2,2,3,4,4,3] Output: true Example 2: Input: root = [1,2…
原文链接: https://leetcode-cn.com/problems/binary-tree-level-order-traversal 英文原文Given the root of a binary tree, return the level order traversal of its nodes' values. (i.e., from left to right, level by level). Example 1: Input: root = [3,9,20,null,nul…
原文链接: https://leetcode-cn.com/problems/maximum-depth-of-binary-tree 英文原文Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest lea…
原文链接: https://leetcode-cn.com/problems/binary-tree-level-order-traversal-ii 英文原文Given the root of a binary tree, return the bottom-up level order traversal of its nodes' values. (i.e., from left to right, level by level from leaf to root). Example 1:…
原文链接: https://leetcode-cn.com/problems/minimum-depth-of-binary-tree 英文原文Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a …
原文链接: https://leetcode-cn.com/problems/populating-next-right-pointers-in-each-node 英文原文You are given a perfect binary tree where all leaves are on the same level, and every parent has two children. The binary tree has the following definition: struct…
原文链接: https://leetcode-cn.com/problems/populating-next-right-pointers-in-each-node-ii 英文原文Given a binary tree struct Node { int val; Node *left; Node *right; Node *next; } Populate each next pointer to point to its next right node. If there is no nex…
原文链接: https://leetcode-cn.com/problems/word-ladder-ii 英文原文A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that: Every adjacent pair of words diff…
原文链接: https://leetcode-cn.com/problems/word-ladder 英文原文A transformation sequence from word beginWord to word endWord using a dictionary wordList is a sequence of words beginWord -> s1 -> s2 -> ... -> sk such that: Every adjacent pair of words differs…
原文链接: https://leetcode-cn.com/problems/surrounded-regions 英文原文Given an m x n matrix board containing 'X' and 'O', capture all regions that are 4-directionally surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded r…
原文链接: https://leetcode-cn.com/problems/clone-graph 英文原文Given a reference of a node in a connected undirected graph. Return a deep copy (clone) of the graph. Each node in the graph contains a value (int) and a list (List[Node]) of its neighbors. class…
原文链接: https://leetcode-cn.com/problems/binary-tree-right-side-view 英文原文Given the root of a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example 1: Input: root =…
原文链接: https://leetcode-cn.com/problems/number-of-islands 英文原文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 adjacen…
原文链接: https://leetcode-cn.com/problems/course-schedule 英文原文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] = [ai, bi] indicates that you must take…
原文链接: https://leetcode-cn.com/problems/course-schedule-ii 英文原文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] = [ai, bi] indicates that you must t…
原文链接: https://leetcode-cn.com/problems/invert-binary-tree 英文原文Given the root of a binary tree, invert the tree, and return its root. Example 1: Input: root = [4,2,7,1,3,6,9] Output: [4,7,2,9,6,3,1] Example 2: Input: root = [2,1,3] Output: [2,3,1] Exa…
原文链接: https://leetcode-cn.com/problems/perfect-squares 英文原文Given an integer n, return the least number of perfect square numbers that sum to n. A perfect square is an integer that is the square of an integer; in other words, it is the product of some…
原文链接: https://leetcode-cn.com/problems/serialize-and-deserialize-binary-tree 英文原文Serialization is the process of converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across …
原文链接: https://leetcode-cn.com/problems/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. Return all the possible results. You may re…
原文链接: https://leetcode-cn.com/problems/minimum-height-trees 英文原文A tree is an undirected graph in which any two vertices are connected by exactly one path. In other words, any connected graph without simple cycles is a tree. Given a tree of n nodes la…
原文链接: https://leetcode-cn.com/problems/coin-change 英文原文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 m…
原文链接: https://leetcode-cn.com/problems/longest-increasing-path-in-a-matrix 英文原文Given an m x n integers matrix, return the length of the longest increasing path in matrix. From each cell, you can either move in four directions: left, right, up, or dow…
原文链接: https://leetcode-cn.com/problems/water-and-jug-problem 英文原文You are given two jugs with capacities jug1Capacity and jug2Capacity liters. There is an infinite amount of water supply available. Determine whether it is possible to measure exactly t…
原文链接: https://leetcode-cn.com/problems/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]. Each Ai or Bi…
原文链接: https://leetcode-cn.com/problems/sum-of-left-leaves 英文原文Given the root of a binary tree, return the sum of all left leaves. Example 1: Input: root = [3,9,20,null,null,15,7] Output: 24 Explanation: There are two left leaves in the binary tree, w…
原文链接: https://leetcode-cn.com/problems/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. Example 1: Input: heightM…
原文链接: https://leetcode-cn.com/problems/pacific-atlantic-water-flow 英文原文There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touc…
原文链接: https://leetcode-cn.com/problems/minimum-genetic-mutation 英文原文A gene string can be represented by an 8-character long string, with choices from 'A', 'C', 'G', and 'T'. Suppose we need to investigate a mutation from a gene string start to a gene…
原文链接: https://leetcode-cn.com/problems/serialize-and-deserialize-bst 英文原文Serialization is converting a data structure or object into a sequence of bits so that it can be stored in a file or memory buffer, or transmitted across a network connection li…
1 / 6