• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2015年12月29日
Leetcode: Range Sum Query 2D - Immutable
摘要: 阅读全文
posted @ 2015-12-29 09:25 neverlandly 阅读(320) 评论(0) 推荐(0)
Leetcode: Range Sum Query - Immutable
摘要: Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example: Given nums = [-2, 0, 3, -5, 2, -1] sumR 阅读全文
posted @ 2015-12-29 08:56 neverlandly 阅读(227) 评论(0) 推荐(0)
Leetcode: Smallest Rectangle Enclosing Black Pixels
摘要: An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one bla 阅读全文
posted @ 2015-12-29 08:28 neverlandly 阅读(935) 评论(0) 推荐(0)
Leetcode: Longest Increasing Subsequence
摘要: 讲解一: 用一个数组来存 the smallest tail of all increasing subsequences with length i+1 in tails[i]. For example, say we have nums = [4,5,6,3], then all the ava 阅读全文
posted @ 2015-12-29 06:07 neverlandly 阅读(424) 评论(0) 推荐(0)
Leetcode: Bulls and Cows
摘要: Be careful, when calculate B, you should exclude A's cases 阅读全文
posted @ 2015-12-29 04:52 neverlandly 阅读(335) 评论(0) 推荐(0)
Leetcode: Serialize and Deserialize Binary Tree
摘要: Referring this post: https://leetcode.com/problems/serialize-and-deserialize-binary-tree/discuss/74253/Easy-to-understand-Java-Solution But instead us 阅读全文
posted @ 2015-12-29 03:16 neverlandly 阅读(376) 评论(0) 推荐(0)
Leetcode: Binary Tree Longest Consecutive Sequence
摘要: 递归法 复杂度 时间O(n) 空间O(h) 思路 因为要找最长的连续路径,我们在遍历树的时候需要两个信息,一是目前连起来的路径(curLen)有多长(以当前节点为终点),二是目前路径的上一个节点的值(preVal)。 每一次递归,先检查当前节点是否比上一节点大1, 是,curLen++, 否curL 阅读全文
posted @ 2015-12-29 01:11 neverlandly 阅读(361) 评论(0) 推荐(0)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3