IncredibleThings

导航

2018年5月21日 #

LeetCode - Kth Smallest Element in a BST

摘要: 那么这道题给的提示是让我们用BST的性质来解题,最重要的性质是就是左<根<右,那么如果用中序遍历所有的节点就会得到一个有序数组。所以解题的关键还是中序遍历啊。 阅读全文

posted @ 2018-05-21 12:10 IncredibleThings 阅读(88) 评论(0) 推荐(0) 编辑

LeetCode - LRU Cache

摘要: 此题的思路是运用hashmap和double linked nodes The hash makes the time of get() to be O(1). The list of double linked nodes make the nodes adding/removal operati 阅读全文

posted @ 2018-05-21 10:42 IncredibleThings 阅读(105) 评论(0) 推荐(0) 编辑

LeetCode - Median of Two Sorted Arrays

摘要: 题目要求time complexity 是O(log (m+n)), 先归并排序也是不可行的, 时间复杂度为O(m+n) 阅读全文

posted @ 2018-05-21 03:45 IncredibleThings 阅读(103) 评论(0) 推荐(0) 编辑

LeetCode - Word Ladder

摘要: Given two words (beginWord and endWord), and a dictionary's word list, find the length of shortest transformation sequence from beginWord to endWord, 阅读全文

posted @ 2018-05-21 01:16 IncredibleThings 阅读(112) 评论(0) 推荐(0) 编辑