摘要: 1 public class FindKthSorted { 2 //Method 1: time complexity O(k), no extra space 3 4 public int findKth (int[] a, int[] b, int k) { 5 ... 阅读全文
posted @ 2015-07-23 07:48 GoNuts 阅读(181) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointe... 阅读全文
posted @ 2015-07-23 02:26 GoNuts 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 求non-preemptive Shortest Job First与Round Robin的平均等待时间。输入为两个array,一个为到达时间,一个为执行时间。对于Round Robin还另外有time slice.直接看代码吧。思路挺直接的,就想象自己就是处理器,有一个CPU时间一直在走,到点该... 阅读全文
posted @ 2015-07-20 11:43 GoNuts 阅读(665) 评论(0) 推荐(0) 编辑
摘要: 题目:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations:getandset.get(key)- Get the v... 阅读全文
posted @ 2015-07-17 10:43 GoNuts 阅读(256) 评论(0) 推荐(0) 编辑
摘要: 题目:h-score is a score that publishers get if articles that they publish get citations in other articles. A publisher gets h-score of x if they wrote a... 阅读全文
posted @ 2015-07-17 00:03 GoNuts 阅读(278) 评论(0) 推荐(0) 编辑
摘要: Given a Binary Tree and a key, write a function that returns level of the key.For example, consider the following tree. If the input key is 3, then yo... 阅读全文
posted @ 2015-07-16 12:28 GoNuts 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two nu... 阅读全文
posted @ 2015-07-15 12:39 GoNuts 阅读(189) 评论(0) 推荐(0) 编辑
摘要: Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a... 阅读全文
posted @ 2015-07-15 11:45 GoNuts 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ... 阅读全文
posted @ 2015-07-15 09:38 GoNuts 阅读(141) 评论(0) 推荐(0) 编辑
摘要: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to thedefinition of LCA on Wikipedia: ... 阅读全文
posted @ 2015-07-12 02:33 GoNuts 阅读(189) 评论(0) 推荐(0) 编辑