随笔分类 -  CareerCup

上一页 1 ··· 3 4 5 6 7 8 下一页
摘要:4.8 You have two very large binary trees: Tl, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree... 阅读全文
posted @ 2015-08-08 11:03 Grandyang 阅读(690) 评论(0) 推荐(0) 编辑
摘要:4.7 Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree. Avoid storing additional nodes in a data struc... 阅读全文
posted @ 2015-08-07 23:28 Grandyang 阅读(893) 评论(0) 推荐(0) 编辑
摘要:4.6 Write an algorithm to find the'next'node (i.e., in-order successor) of a given node in a binary search tree. You may assume that each node has a l... 阅读全文
posted @ 2015-08-06 23:26 Grandyang 阅读(1190) 评论(0) 推荐(0) 编辑
摘要:4.5 Implement a function to check if a binary tree is a binary search tree.LeetCode上的原题,请参见我之前的博客Validate Binary Search Tree 验证二叉搜索树。 阅读全文
posted @ 2015-08-03 23:38 Grandyang 阅读(585) 评论(0) 推荐(0) 编辑
摘要:4.4 Given a binary tree, design an algorithm which creates a linked list of all the nodes at each depth (e.g., if you have a tree with depth D, you'll... 阅读全文
posted @ 2015-08-01 23:21 Grandyang 阅读(564) 评论(0) 推荐(0) 编辑
摘要:4.3 Given a sorted (increasing order) array with unique integer elements, write an algorithm to create a binary search tree with minimal height.这道题给了我... 阅读全文
posted @ 2015-07-31 23:24 Grandyang 阅读(731) 评论(0) 推荐(0) 编辑
摘要:4.2 Given a directed graph, design an algorithm to find out whether there is a route between two nodes.LeetCode和CareerCup中关于图的题都不是很多,LeetCode中只有三道,分别是... 阅读全文
posted @ 2015-07-30 23:50 Grandyang 阅读(1072) 评论(0) 推荐(0) 编辑
摘要:4.1 Implement a function to check if a binary tree is balanced. For the purposes of this question, a balanced tree is defined to be a tree such that t... 阅读全文
posted @ 2015-07-29 13:11 Grandyang 阅读(783) 评论(0) 推荐(0) 编辑
摘要:3.7 An animal shelter holds only dogs and cats, and operates on a strictly "first in, first out" basis. People must adopt either the "oldest" (based o... 阅读全文
posted @ 2015-07-28 12:59 Grandyang 阅读(775) 评论(0) 推荐(0) 编辑
摘要:3.6 Write a program to sort a stack in ascending order (with biggest items on top). You may use at most one additional stack to hold items, but you ma... 阅读全文
posted @ 2015-07-27 06:14 Grandyang 阅读(3634) 评论(0) 推荐(0) 编辑
摘要:3.5 Implement a MyQueue class which implements a queue using two stacks.LeetCode上的原题,请参见我之前的博客Implement Queue using Stacks 用栈来实现队列。 阅读全文
posted @ 2015-07-27 00:47 Grandyang 阅读(742) 评论(0) 推荐(0) 编辑
摘要:3.4 In the classic problem of the Towers of Hanoi, you have 3 towers and N disks of different sizes which can slide onto any tower. The puzzle starts ... 阅读全文
posted @ 2015-07-26 11:45 Grandyang 阅读(1748) 评论(0) 推荐(0) 编辑
摘要:3.3 Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when ... 阅读全文
posted @ 2015-07-26 08:08 Grandyang 阅读(1169) 评论(0) 推荐(0) 编辑
摘要:3.2 How would you design a stack which, in addition to push and pop, also has a function min which returns the minimum element? Push, pop and min shou... 阅读全文
posted @ 2015-07-25 12:55 Grandyang 阅读(691) 评论(0) 推荐(0) 编辑
摘要:3.1 Describe how you could use a single array to implement three stacks.这道题让我们用一个数组来实现三个栈,书上给了两种方法,第一种方法是定长分割 Fixed Division,就是每个栈的长度相同,用一个公用的一位数组buff... 阅读全文
posted @ 2015-07-25 12:06 Grandyang 阅读(1593) 评论(0) 推荐(0) 编辑
摘要:2.7 Implement a function to check if a linked list is a palindrome.LeetCode上的原题,参见我之前的博客Palindrome Linked List 回文链表。 阅读全文
posted @ 2015-07-22 21:00 Grandyang 阅读(710) 评论(0) 推荐(0) 编辑
摘要:2.6 Given a circular linked list, implement an algorithm which returns the node at the beginning of the loop.DEFINITIONCircular linked list: A (corrup... 阅读全文
posted @ 2015-07-21 20:40 Grandyang 阅读(673) 评论(0) 推荐(0) 编辑
摘要:2.5 You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the ... 阅读全文
posted @ 2015-07-20 20:42 Grandyang 阅读(5817) 评论(1) 推荐(0) 编辑
摘要:2.4 Write code to partition a linked list around a value x, such that all nodes less than x come before all nodes greater than or equal to x.LeetCode上... 阅读全文
posted @ 2015-07-20 12:57 Grandyang 阅读(804) 评论(0) 推荐(0) 编辑
摘要:2.3 Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node.EXAMPLEInput: the node c from the li... 阅读全文
posted @ 2015-07-19 12:31 Grandyang 阅读(950) 评论(0) 推荐(0) 编辑

上一页 1 ··· 3 4 5 6 7 8 下一页
Fork me on GitHub