摘要: Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get and set. get(key) - Get the 阅读全文
posted @ 2016-01-28 12:45 fenshen371 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For exa 阅读全文
posted @ 2016-01-28 10:43 fenshen371 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 共有三种思路。 哈希表。 将较小的那个数组中的所有元素存在哈希表中。然后依次验证另一个数组中的数字是否有出现过。时间复杂度O(m + n),空间复杂度O(min(m, n)) 二分搜索法 将较小的那个数组中的每一个元素,都用二分搜索的方法在较大数组中验证是否出现过。当两个数组大小相差很大时,这种方法 阅读全文
posted @ 2016-01-28 07:59 fenshen371 阅读(122) 评论(0) 推荐(0) 编辑