![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
bw_yyziq
业精于勤,荒于嬉
展开
-
leetcode 144 145 二叉树的遍历 141 142 环状链表 149 穷举法
[144] binary-tree-preorder-traversal 二叉树的前序遍历使用栈,不用递归/** * Definition for binary tree * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { ...原创 2018-04-07 17:11:47 · 181 阅读 · 0 评论 -
leetcode 104 22 46
【104】maximum-depth-of-binary-tree(二叉树的最大深度)public class Solution { public int maxDepth(TreeNode root) { if(root == null) { return 0; } return 1 + Math.max(maxDepth(root.left), maxDepth(root....原创 2018-03-31 00:22:06 · 125 阅读 · 0 评论 -
leetcode 134 62 63 67 143
【134】gas-station public class Solution { public int canCompleteCircuit(int[] gas, int[] cost) { int len = gas.length; for (int i = 0; i < len; i++) { int total = 0; int j = i; while ...原创 2018-04-01 22:59:30 · 166 阅读 · 0 评论 -
leetcode 133 clone-graph 克隆图(图的遍历算法)
题目描述 克隆一个无向图. 图中每个节点包括一个 label 和一个放置其邻居的 list. 节点结构体定义如下:class UndirectedGraphNode { int label; ArrayList<UndirectedGraphNode> neighbors; UndirectedGraphNode(int x) { label = x; nei...原创 2018-04-03 12:14:08 · 1238 阅读 · 3 评论 -
leetcode 139 140 动态规划
[139] word-break (动态规划)维护一个数组,存放从第字符串一个字符开始是否可以由字典中的单词组成,这样,如果想知道长为n的字符串是否可由字典中的单词组成,仅需要知道从这个字符之前任意一个判断为能的字符之后,组成的字符串在字典中即可。import java.util.*; public class Solution { public boolean wordBreak(S...原创 2018-04-05 16:31:09 · 533 阅读 · 0 评论