• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2015年12月22日
Leetcode: Add Digits
摘要: 我的方法:注意最方便的获取一个数每一位的方法,是把它转化为String先,通过String.valueOf(int c) O(1): http://my.oschina.net/Tsybius2014/blog/497645 另一个方法比较简单,可以举例说明一下。假设输入的数字是一个5位数字num, 阅读全文
posted @ 2015-12-22 13:28 neverlandly 阅读(240) 评论(0) 推荐(0)
Leetcode: Binary Tree Paths
摘要: Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->... 阅读全文
posted @ 2015-12-22 12:44 neverlandly 阅读(274) 评论(0) 推荐(0)
Leetcode: Verify Preorder Sequence in Binary Search Tree
摘要: 4 / \ 2 6 / \ / \ 1 3 5 7 如图所示BST, preorder结果是 4 2 1 3 6 5 7 4是root, 213是左子树,657是右子树 idea就是右子树不能再出现比root小的数,一旦出现,return false. 这样一层一层recursion, 直到子树只剩 阅读全文
posted @ 2015-12-22 11:16 neverlandly 阅读(293) 评论(0) 推荐(0)
Leetcode: Meeting Rooms II
摘要: Like the previous one Meeting Room, still need to sort the intervals using a comparator. We need to simulate the process to know the maximum number of 阅读全文
posted @ 2015-12-22 09:19 neverlandly 阅读(943) 评论(0) 推荐(0)
Leetcode: Meeting Rooms
摘要: Interval as an array: Previous interval as an object: Implement a Comparator<Interval> Syntax: don't forget the public sign when defining a function 阅读全文
posted @ 2015-12-22 08:32 neverlandly 阅读(298) 评论(0) 推荐(0)
Leetcode: Flatten 2D Vector
摘要: Implement an iterator to flatten a 2d vector.For example,Given 2d vector =[ [1,2], [3], [4,5,6]]By calling next repeatedly until hasNext returns fa... 阅读全文
posted @ 2015-12-22 08:13 neverlandly 阅读(278) 评论(0) 推荐(0)
Leetcode: Count Univalue Subtrees
摘要: Given a binary tree, count the number of uni-value subtrees.A Uni-value subtree means all nodes of the subtree have the same value.For example:Given b... 阅读全文
posted @ 2015-12-22 07:22 neverlandly 阅读(1741) 评论(0) 推荐(0)
Leetcode: Group Shifted Strings
摘要: Given a string, we can "shift" each of its letter to its successive letter, for example: "abc" -> "bcd". We can keep "shifting" which forms the sequen... 阅读全文
posted @ 2015-12-22 02:04 neverlandly 阅读(435) 评论(0) 推荐(0)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3