• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2016年12月16日
Leetcode: Plus One Linked List
摘要: Solution: Use Stack, O(N) space my another solution: don't create new node, modify the existed node Solution 3: reverse the inputs, add one, then reve 阅读全文
posted @ 2016-12-16 13:31 neverlandly 阅读(284) 评论(0) 推荐(0)
Leetcode: Sort Transformed Array
摘要: 参考:https://discuss.leetcode.com/topic/48424/java-o-n-incredibly-short-yet-easy-to-understand-ac-solution the problem seems to have many cases a>0, a=0 阅读全文
posted @ 2016-12-16 12:31 neverlandly 阅读(225) 评论(0) 推荐(0)
Leetcode: Rearrange String k Distance Apart
摘要: Analysis: Solution 1: The greedy algorithm is that in each step, select the char with highest remaining count if possible (if it is not in the waiting 阅读全文
posted @ 2016-12-16 11:25 neverlandly 阅读(821) 评论(0) 推荐(0)
Leetcode: Line Reflection
摘要: 本题精妙之处在于:1. 如何最快找到possible的line的x axis(我最开始想到要用quickselect find median的方法,结果别人有min max方法) 2. 如何最方便确定一个点关于该line的reflection是否存在,由于既有x又有y,不太好处理,别人有个聪明的办法 阅读全文
posted @ 2016-12-16 06:24 neverlandly 阅读(252) 评论(0) 推荐(0)
Leetcode: Logger Rate Limiter
摘要: HashMap 阅读全文
posted @ 2016-12-16 05:10 neverlandly 阅读(403) 评论(0) 推荐(0)
Leetcode: Design Snake Game
摘要: HashSet + Queue: 吃东西的时候保留尾巴,不吃的时候删去尾巴 one case to notice蛇转弯的时候,要先删去尾巴,再把新的点加进去。如果这个顺序不对的话,本来不会撞上尾巴的结果会判断会撞上 如果没有39行,程序会说dir没有initialize, 其实更好的写法应该是 阅读全文
posted @ 2016-12-16 04:53 neverlandly 阅读(524) 评论(0) 推荐(0)
Leetcode: Android Unlock Patterns
摘要: 我自己的backtracking做法 最开始把cur设置为一个dummy value 0 最好的DFS with Optimization beat 97%: https://discuss.leetcode.com/topic/46260/java-dfs-solution-with-clear- 阅读全文
posted @ 2016-12-16 02:01 neverlandly 阅读(545) 评论(0) 推荐(0)
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3