Leetcode 101. Symmetric Tree 化用深度搜索

Leetcode 101. Symmetric Tree 化用深度搜索

Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the following [1,2,2,null,3,null,3] is not: 1 

Leetcode 279. Perfect Squares 经典一维动态规划问题

Leetcode 279. Perfect Squares 经典一维动态规划问题

题目表述 Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, …) which sum to n. Example 1: Input: n = 12 Output: 3 Explanation: 12 = 4 + 4 + 4. Example 2: Input: n 

Leetcode 102. Binary Tree Level Order Traversal 基本层次遍历

Leetcode 102. Binary Tree Level Order Traversal 基本层次遍历

Given a binary tree, return the level order traversal of its nodes’ values. (ie, from left to right, level by level). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its level order traversal as: [ [3], [9,20], 

Leetcode 286. Walls and Gates 联通类型问题

Leetcode 286. Walls and Gates 联通类型问题

题目表述 You are given a m x n 2D grid initialized with these three possible values. -1 – A wall or an obstacle. 0 – A gate. INF – Infinity means an empty room. We use the value 231 – 1 = 2147483647 to represent 

Leetcode 200. Number of Islands 典型联通问题探讨

Leetcode 200. Number of Islands 典型联通问题探讨

题目大意 Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded 

Leetcode 199 Binary Tree Right Side View 层次遍历变形

Leetcode 199 Binary Tree Right Side View 层次遍历变形

题目大意 Given 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: Input: [1,2,3,null,5,null,4] Output: [1, 3, 4] Explanation: 1 <— / \ 2 3 <— \ \ 

Leetcode 111. Minimum Depth of Binary Tree 深度优先递归遍历

Leetcode 111. 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 node with no children. Example: Given binary tree [3,9,20,null,null,15,7], 

Leetcode 107 Binary Tree Level Order Traversal II 层次遍历及其变形

Leetcode 107 Binary Tree Level Order Traversal II 层次遍历及其变形

题目分析 Given a binary tree, return the bottom-up level order traversal of its nodes’ values. (ie, from left to right, level by level from leaf to root). For example: Given binary tree [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 return its bottom-up