• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2016年11月24日
Leetcode: Valid Perfect Square
摘要: 我的binary Search 解法:无需变成long 别人三种方法总结: 阅读全文
posted @ 2016-11-24 12:50 neverlandly 阅读(327) 评论(0) 推荐(0)
Leetcode: Intersection of Two Arrays II
摘要: 用HashMap Follow Up 1: 用two pointer解,可以省存成HashMap Follow Up 2: 用在长的数组里面binary Search可解 Follow Up 3: What if elements of nums2 are stored on disk, and t 阅读全文
posted @ 2016-11-24 11:52 neverlandly 阅读(283) 评论(0) 推荐(0)
Leetcode: Intersection of Two Arrays
摘要: Use two hash sets Time complexity: O(n) 注意Set<Integer> set = new HashSet<>(); 第二个泛型可以不写出 Iterator iter = set2.iterator(); for (int i=0; i<res.length; 阅读全文
posted @ 2016-11-24 10:34 neverlandly 阅读(315) 评论(0) 推荐(0)
Leetcode: Top K Frequent Elements
摘要: 很像majority element III, 但是那道题有O(k) extra space的限制,这里没有。有任意extra space, 同时知道elem range情况下,bucket sort最节省时间 语法上注意第5行,建立一个ArrayList的array,后面没有泛型generic L 阅读全文
posted @ 2016-11-24 06:51 neverlandly 阅读(310) 评论(0) 推荐(0)
Leetcode: Reverse Vowels of a String
摘要: Two Pointers 解法, 注意大小写 阅读全文
posted @ 2016-11-24 05:20 neverlandly 阅读(273) 评论(0) 推荐(0)
Leetcode: Integer Break
摘要: O(N^2)解法: DP dp[i] represent the maximum product of breaking up integer i O(N)解法: the best factor is 3. we keep breaking n into 3's until n gets small 阅读全文
posted @ 2016-11-24 04:57 neverlandly 阅读(353) 评论(0) 推荐(0)
Leetcode: Flatten Nested List Iterator
摘要: 非常精巧地使用stack。push all the nestedList into the stack from back to front,so when we pop the stack, it returns the very first element 执行hasNext()的时候,如果pe 阅读全文
posted @ 2016-11-24 01:29 neverlandly 阅读(418) 评论(0) 推荐(0)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3