算法
weixin_38783585
这个作者很懒,什么都没留下…
展开
-
树的最小的深度
链接:https://www.nowcoder.com/questionTerminal/e08819cfdeb34985a8de9c4e6562e724来源:牛客网Given a binary tree, find its minimum depth.The minimum depth is thenumber of nodes along the shortest path from the ...原创 2018-04-11 20:52:20 · 155 阅读 · 0 评论 -
二叉树中和为某一值的路径
import java.util.ArrayList;import java.util.Stack;import java.util.Collections;/**public class TreeNode { int val = 0; TreeNode left = null; TreeNode right = null; public TreeNode(int val)...原创 2018-04-20 22:18:14 · 102 阅读 · 0 评论 -
367. Valid Perfect Square
method1 simple but not allow public boolean isPerfectSquare(int num) { int sqrt = (int) Math.sqrt(num); return sqrt * sqrt == num; } method2 newto method public boolean isP...原创 2019-07-11 10:32:28 · 142 阅读 · 0 评论 -
374. Guess Number Higher or Lower
this is a binary search problem. code show as below: public class Solution extends GuessGame { public int guessNumber(int n) { int left = 1, right = n; while (left < right) { ...原创 2019-07-11 10:58:24 · 130 阅读 · 0 评论