• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
neverlandly
博客园    首页    新随笔    联系   管理    订阅  订阅
2015年12月21日
Leetcode: Paint House
摘要: The same with F面经 Better Solution: O(N) time, O(1) space 阅读全文
posted @ 2015-12-21 13:34 neverlandly 阅读(336) 评论(0) 推荐(0)
Leetcode: Strobogrammatic Number III
摘要: A strobogrammatic number is a number that looks the same when rotated 180 degrees (looked at upside down).Write a function to count the total strobogr... 阅读全文
posted @ 2015-12-21 12:53 neverlandly 阅读(340) 评论(0) 推荐(0)
Leetcode: Strobogrammatic Number II
摘要: Watch out for cornor case: when n = 2, there shouldn't be "00" returned. but when n = 4, which uses n =2 as recursion base, "1001" is an answer 阅读全文
posted @ 2015-12-21 09:30 neverlandly 阅读(310) 评论(0) 推荐(0)
Leetcode: Strobogrammatic Number
摘要: Related to confusing number O(N) time and O(N) space O(N) time and O(1) space, use two pointers 阅读全文
posted @ 2015-12-21 07:11 neverlandly 阅读(292) 评论(0) 推荐(0)
Leetcode: Shortest Word Distance III
摘要: This is a follow up of Shortest Word Distance. The only difference is now word1 could be the same as word2.Given a list of words and two words word1 a... 阅读全文
posted @ 2015-12-21 06:40 neverlandly 阅读(281) 评论(0) 推荐(0)
Leetcode: Shortest Word Distance II
摘要: This is a follow up of Shortest Word Distance. The only difference is now you are given the list of words and your method will be called repeatedly ma... 阅读全文
posted @ 2015-12-21 04:34 neverlandly 阅读(322) 评论(0) 推荐(0)
Leetcode: Shortest Word Distance
摘要: 双指针法:time O(N), space O(1) 一个指针指向word1上次出现的位置,一个指针指向word2上次出现的位置。因为两个单词如果比较接近的话,肯定是相邻的word1和word2的位置之差,所以我们只要每次得到一个新位置和另一个单词的位置比较一下就行了。 阅读全文
posted @ 2015-12-21 00:57 neverlandly 阅读(305) 评论(0) 推荐(0)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3