2016年1月24日

LRU Cache

摘要: Question:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get... 阅读全文

posted @ 2016-01-24 04:20 BillZ 阅读(149) 评论(0) 推荐(0) 编辑

2016年1月22日

Max Tree

摘要: Question:Given an integer array with no duplicates. A max tree building on this array is defined as follow:The root is the maximum number in the array... 阅读全文

posted @ 2016-01-22 15:44 BillZ 阅读(130) 评论(0) 推荐(0) 编辑

Largest Rectangle in Histogram

摘要: Question:Givennnon-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in t... 阅读全文

posted @ 2016-01-22 13:59 BillZ 阅读(128) 评论(0) 推荐(0) 编辑

Majority Number III

摘要: Question:Given an array of integers and a number k, the majority number is the number that occursmore than 1/kof the size of the array.Find it.Example... 阅读全文

posted @ 2016-01-22 06:57 BillZ 阅读(109) 评论(0) 推荐(0) 编辑

2016年1月20日

Trailing Zeros (Factorial)

摘要: Question:Write an algorithm which computes the number of trailing zeros in n factorial.Example:11! = 39916800, so the out should be 2Analysis:所有大于2的整数... 阅读全文

posted @ 2016-01-20 15:41 BillZ 阅读(169) 评论(0) 推荐(0) 编辑

2016年1月18日

Maximum Subarray III

摘要: Question:Given an array of integers and a numberk, find knon-overlappingsubarrays which have the largest sum.The number in each subarray should becont... 阅读全文

posted @ 2016-01-18 14:43 BillZ 阅读(310) 评论(0) 推荐(0) 编辑

2016年1月16日

Convert Binary Search Tree to Doubly Linked List

摘要: Question: Convert a binary search tree to doubly linked list with in-order traversal. Example: Given a binary search tree: 4 / \ 2 5 / \ 1 3 return 1< 阅读全文

posted @ 2016-01-16 15:37 BillZ 阅读(659) 评论(0) 推荐(0) 编辑

2016年1月11日

Convert Sorted List to Balanced BST

摘要: Question: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. Example: 2 1->2->3 => / \ 1 3 阅读全文

posted @ 2016-01-11 16:37 BillZ 阅读(258) 评论(0) 推荐(0) 编辑

2015年12月31日

Remove Node in Binary Search Tree

摘要: Question:Given a root of Binary Search Tree with unique value for each node. Remove the node with given value. If there is no such a node with given v... 阅读全文

posted @ 2015-12-31 09:48 BillZ 阅读(482) 评论(0) 推荐(0) 编辑

2015年12月23日

Binary Tree Path Sum

摘要: Question:Given a binary tree, find all paths that sum of the nodes in the path equals to a given numbertarget.A valid path is from root node to any of... 阅读全文

posted @ 2015-12-23 09:56 BillZ 阅读(393) 评论(0) 推荐(0) 编辑

导航