dfs
Opium_Z
这个作者很懒,什么都没留下…
展开
-
Leetcode 199 Binary Tree Right Side View
Problem: 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. Input: [1,2,3,null,5,null,4] Output: [1, 3, 4] E...原创 2019-04-06 06:57:00 · 86 阅读 · 0 评论 -
Leetcode 17 Letter Combinations of a Phone Number
problem: Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. A mapping of digit to letters is just like on the telephone butto...翻译 2019-04-03 12:22:04 · 108 阅读 · 0 评论 -
Leetcode 91 Decode Ways
Problem: A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given a non-empty string containing only digits, determin...原创 2019-04-10 04:58:28 · 109 阅读 · 0 评论 -
Leetcode 200 Number of Islands
Problem: Analysis scan grid to find ‘1’ if ‘1’, then dfs or bfs and label Code class Solution1 { // 1. scan grid 2.if ==1, dfs and label final static int[][] dirs = {{1,0},{-1,0},{0,1},...原创 2019-06-07 13:20:00 · 88 阅读 · 0 评论 -
Leetcode Permutation
Problem Give a string, like “abc”, return all the possible combinations (all the chars are different) example: input: “abc” output: [abc, acb, bac, bca, cab, cba] Analysis obviously, this problem can ...原创 2019-06-07 23:36:09 · 197 阅读 · 0 评论 -
Leetcode 124. Binary Tree Maximum Path Sum
Problem: Analysis: In this problem, I gonna use DFS to solve it. By using recursion, we should set up the base rule and recursive rule. there is a small trick in this problem, we should pass the int[...原创 2019-06-26 04:02:15 · 102 阅读 · 0 评论