摘要:
The same with F面经 Better Solution: O(N) time, O(1) space 阅读全文
posted @ 2015-12-21 13:34
neverlandly
阅读(336)
评论(0)
推荐(0)
摘要:
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)
摘要:
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)
摘要:
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)
摘要:
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)
摘要:
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)
摘要:
双指针法:time O(N), space O(1) 一个指针指向word1上次出现的位置,一个指针指向word2上次出现的位置。因为两个单词如果比较接近的话,肯定是相邻的word1和word2的位置之差,所以我们只要每次得到一个新位置和另一个单词的位置比较一下就行了。 阅读全文
posted @ 2015-12-21 00:57
neverlandly
阅读(305)
评论(0)
推荐(0)
浙公网安备 33010602011771号