摘要: 作者:LeetCode链接:https://leetcode-cn.com/problems/number-of-islands/solution/dao-yu-shu-liang-by-leetcode/来源:力扣(LeetCode)著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出 阅读全文
posted @ 2020-05-25 09:08 弓呆的胖次 阅读(156) 评论(0) 推荐(0) 编辑
摘要: 很简单,来个层次遍历,当遍历队列,遍历到刚开始遍历时,队列里最后一个数时(也就是遍历len-1次),得到的就是右视图的其中一个节点 /** * Definition for a binary tree node. * public class TreeNode { * int val; * Tree 阅读全文
posted @ 2020-05-25 08:44 弓呆的胖次 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 直接看代码吧 class Solution { public int rob(int[] nums) { if(nums.length==0) return 0; if(nums.length==1) return nums[0]; if(nums.length==2) { if(nums[0]>n 阅读全文
posted @ 2020-05-25 08:40 弓呆的胖次 阅读(110) 评论(0) 推荐(0) 编辑