
leetcode深度优先搜索
文章平均质量分 51
leetcode深度优先搜索
Bryan要加油
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
987. Vertical Order Traversal of a Binary Tree[Hard](Leetcode每日一题-2021.07.31)
ProblemGiven the root of a binary tree, calculate the vertical order traversal of the binary tree.For each node at position (row, col), its left and right children will be at positions (row + 1, col - 1) and (row + 1, col + 1) respectively. The root of t原创 2021-07-31 22:44:33 · 306 阅读 · 0 评论 -
863. All Nodes Distance K in Binary Tree[Medium](Leetcode每日一题-2021.07.27)
Problem原创 2021-07-31 22:40:01 · 178 阅读 · 0 评论 -
671. Second Minimum Node In a Binary Tree[Easy](Leetcode每日一题-2021.07.27)
ProblemGiven a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node. If the node has two sub-nodes, then this node’s value is the smaller value among its two sub-nodes原创 2021-07-27 19:34:53 · 317 阅读 · 0 评论 -
726. Number of Atoms[Hard](Leetcode每日一题-2021.07.05)--抄答案
ProblemGiven a chemical formula (given as a string), return the count of each atom.The atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name.One or more digits representing that element’s co原创 2021-07-06 21:46:32 · 470 阅读 · 0 评论 -
剑指 Offer 38. 字符串的排列[Medium](Leetcode每日一题-2021.06.22)
Problem输入一个字符串,打印出该字符串中字符的所有排列。你可以以任意顺序返回这个字符串数组,但里面不能有重复元素。限制:1 <= s 的长度 <= 8Example输入:s = “abc”输出:[“abc”,“acb”,“bac”,“bca”,“cab”,“cba”]Solutionclass Solution {public: vector<string> permutation(string s) { vector<原创 2021-06-22 08:32:06 · 622 阅读 · 0 评论 -
1239. Maximum Length of a Concatenated String with Unique Char[Medium](Leetcode每日一题-2021.06.19)--抄答案
ProblemGiven an array of strings arr. String s is a concatenation of a sub-sequence of arr which have unique characters.Return the maximum possible length of s.原创 2021-06-21 22:23:17 · 397 阅读 · 0 评论 -
1723. Find Minimum Time to Finish All Jobs[Hard](Leetcode每日一题-2021.05.08)--抄答案
ProblemYou are given an integer array jobs, where jobs[i] is the amount of time it takes to complete the ith job.There are k workers that you can assign jobs to. Each job should be assigned to exactly one worker. The working time of a worker is the sum o原创 2021-05-08 17:33:16 · 300 阅读 · 0 评论 -
690. Employee Importance(Leetcode每日一题-2021.05.01)
ProblemYou are given a data structure of employee information, which includes the employee’s unique id, their importance value and their direct subordinates’ id.For example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee原创 2021-05-01 16:24:33 · 504 阅读 · 0 评论 -
90. Subsets II(Leetcode每日一题-2021.03.31)
ProblemGiven an integer array nums that may contain duplicates, return all possible subsets (the power set).The solution set must not contain duplicate subsets. Return the solution in any order.Constraints:1 <= nums.length <= 10-10 <= nums[i原创 2021-03-31 21:24:01 · 291 阅读 · 0 评论 -
131. Palindrome Partitioning(Leetcode每日一题-2021.03.07)
ProblemGiven a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s.A palindrome string is a string that reads the same backward as forward.Constraints:1 <= s.length <原创 2021-03-07 09:51:56 · 269 阅读 · 0 评论 -
394. Decode String(Leetcode每日一题-2020.05.28)
ProblemGiven an encoded string, return its decoded string.The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer.You may assume t原创 2020-05-28 23:26:37 · 216 阅读 · 0 评论 -
113. Path Sum II(Leetcode每日一题-2020.09.26)
ProblemGiven a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum.Note: A leaf is a node with no children.ExampleGiven the below binary tree and sum = 22,Return:Solution/** * Definition for a binary tree原创 2020-09-26 12:14:25 · 391 阅读 · 0 评论 -
257. Binary Tree Paths(Leetcode每日一题-2020.09.04)
ProblemGiven a binary tree, return all root-to-leaf paths.Note: A leaf is a node with no children.ExampleSolution/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * Tree原创 2020-09-04 20:28:48 · 151 阅读 · 0 评论 -
841. Keys and Rooms(Leetcode每日一题-2020.08.31)
ProblemThere are N rooms and you start in room 0. Each room has a distinct number in 0, 1, 2, …, N-1, and each room may have some keys to access the next room.Formally, each room i has a list of keys rooms[i], and each key rooms[i][j] is an integer in [原创 2020-08-31 22:45:49 · 155 阅读 · 0 评论 -
332. Reconstruct Itinerary(Leetcode每日一题-2020.08.27)
ProblemGiven a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs from JFK. Thus, the itinerary must begin with JFK.Note:If there原创 2020-08-27 22:31:27 · 207 阅读 · 0 评论 -
17. Letter Combinations of a Phone Number(Leetcode每日一题-2020.08.26)
ProblemGiven a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters原创 2020-08-27 22:29:06 · 196 阅读 · 0 评论 -
491. Increasing Subsequences(Leetcode每日一题-2020.08.25)
ProblemGiven an integer array, your task is to find all the different possible increasing subsequences of the given array, and the length of an increasing subsequence should be at least 2.Constraints:The length of the given array will not exceed 15.Th原创 2020-08-25 21:51:17 · 148 阅读 · 0 评论 -
679. 24 Game (Leetcode每日一题-2020.08.22)
ProblemYou have 4 cards each containing a number from 1 to 9. You need to judge whether they could operated through *, /, +, -, (, ) to get the value of 24.Note:The division operator / represents real division, not integer division. For example, 4 / (1原创 2020-08-22 22:40:54 · 276 阅读 · 0 评论 -
529. Minesweeper(Leetcode每日一题-2020.08.20)
ProblemYou are given a 2D char matrix representing the game board. ‘M’ represents an unrevealed mine, ‘E’ represents an unrevealed empty square, ‘B’ represents a revealed blank square that has no adjacent (above, below, left, right, and all 4 diagonals) m原创 2020-08-20 21:56:07 · 326 阅读 · 0 评论 -
733. Flood Fill(Leetcode每日一题-2020.08.16)
ProblemAn image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535).Given a coordinate (sr, sc) representing the starting pixel (row and column) of the flood fill, and a pixel value newColor原创 2020-08-16 15:42:31 · 269 阅读 · 0 评论 -
130. Surrounded Regions(Leetcode每日一题-2020.08.11)
ProblemGiven a 2D board containing ‘X’ and ‘O’ (the letter O), capture all regions surrounded by ‘X’.A region is captured by flipping all 'O’s into 'X’s in that surrounded region.ExampleSolution从边缘的O开始,进行DFS,找到所有相连的O。然后将所有没有跟边缘的O相连的O标记成X。class Solut原创 2020-08-11 21:34:56 · 223 阅读 · 1 评论 -
93. Restore IP Addresses(Leetcode每日一题-2020.08.09)
ProblemGiven a string containing only digits, restore it by returning all possible valid IP address combinations.A valid IP address consists of exactly four integers (each integer is between 0 and 255) separated by single points.ExampleInput: “2552551原创 2020-08-09 09:52:16 · 312 阅读 · 0 评论 -
337. House Robber III(Leetcode每日一题-2020.08.05)
ProblemThe thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root, each house has one and only one parent house. After a tour, the smart thief realized that “all houses in t原创 2020-08-06 21:27:06 · 199 阅读 · 0 评论 -
207. Course Schedule(Leetcode每日一题-2020.08.04)
ProblemThere are a total of numCourses courses you have to take, labeled from 0 to numCourses-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a pair: [0,1]Given the total number原创 2020-08-04 22:44:03 · 229 阅读 · 0 评论 -
329. Longest Increasing Path in a Matrix(Leetcode每日一题-2020.07.26)
ProblemGiven an integer matrix, find the length of the longest increasing path.From each cell, you can either move to four directions: left, right, up or down. You may NOT move diagonally or move outside of the boundary (i.e. wrap-around is not allowed).原创 2020-07-26 09:47:19 · 235 阅读 · 0 评论 -
200. Number of Islands(Leetcode每日一题-2020.04.20)
占坑原创 2020-04-20 21:01:33 · 289 阅读 · 0 评论 -
365. Water and Jug Problem(Leetcode每日一题-2020.03.21)
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whether it is possible to measure exactly z litres using these two j...原创 2020-03-21 15:24:29 · 378 阅读 · 0 评论 -
695. Max Area of Island(Leetcode每日一题-2020.03.15)
ProblemGiven a non-empty 2D array grid of 0’s and 1’s, an island is a group of 1’s (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid ar...原创 2020-03-15 23:01:19 · 219 阅读 · 0 评论 -
1315. Sum of Nodes with Even-Valued Grandparent
ProblemGiven a binary tree, return the sum of values of nodes with even-valued grandparent. (A grandparent of a node is the parent of its parent, if it exists.)If there are no nodes with an even-va...原创 2020-03-09 22:48:30 · 359 阅读 · 0 评论 -
面试题 04.12. Paths with Sum LCCI
ProblemYou are given a binary tree in which each node contains an integer value (which might be positive or negative). Design an algorithm to count the number of paths that sum to a given value. The ...原创 2020-03-04 20:10:24 · 268 阅读 · 0 评论