自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(57)
  • 收藏
  • 关注

翻译 10.0

Topic 10.01. Scalability question can be among the easiest questions.2. System design problems: just use the following Step-By-Step Approach1)  Make Believe: Pretend that the data can all

2013-10-07 12:55:16 551

翻译 9.0

Topic 9.0 1. Recursive problem can be built off of sub-problems.Problem beginning with following statements might be recursion: “dsign an algorithm to compute the nth…” “Write code to list t

2013-10-06 12:28:48 498

翻译 8.0

Topic 8.01. Step 1: Handel Ambiguity1) 【Obeject-oriented design questions are ofter intentionally vague in order to test whether you’ll make assumptions or if you’ll ask clarifying questions】A

2013-10-06 08:14:02 574

翻译 7.4

Topic 7.4 Write methods to implement the multiply, subtract, and divide operations for integers. Use only the add operator.First ask: is this for int? If no, it is not easy to multiply float or

2013-10-06 00:25:44 615

翻译 12.1

Topic 12.1 Find the mistake(s) in the following code:unsigned int i;For(i=100;i>=0; --i) Printf(“%d\n”,i);// Two mistakes: 1)  Unsigned int is always >=0.虽然打0正确,但循环永远不会结束。If truly wanted

2013-10-05 12:34:21 490

翻译 7.3

Topic 7.3 Given two lines on a Cartesian plane, determine whether the two lines would intersect.注意:考虑边界条件方法:1) If two lines are the same (same slope and y-intercept), they are considered to inte

2013-10-04 17:09:31 625

翻译 7.2

Topic 7.2 There are three ants on different vertices of a triangle. What is the probability of collision (between any two or all of them) if they start walking on the sides of the triangle? Assume t

2013-10-04 16:53:36 507

翻译 7.1

Topic 7.1 You have a basketball hoop and someone says that you can play 1 of 2 games.Game #1: You get one shot to make the hoop.Game #2: You get three shots and you have to make 2 of 3 shots.If

2013-10-04 16:42:26 468

翻译 7.0

Topic 7.0 1. Every number can be decomposed into a product of primes. 84=22*31*50*71*110*130*170.,,2. Greatest common divisor gcd(x, y)=2min(j0,k0)*3min(j1,k1)*5min(j2,k2)*…Least common mult

2013-10-04 15:49:56 506

翻译 5.8

Topic 5.8 A monochrome screen is stored as a single array of bytes, allowing eight consecutive pixels to be stored in one byte. The screen has width w, where w is divisible by 8(that is, no byte wil

2013-10-04 15:11:04 1061

翻译 5.7

Topic 5.7 An array A contains all the integers from 0 to n except for one number which is missing. In this problem, we cannot access an entire integer in A with a single operation. The elements of A a

2013-10-04 06:09:31 922

翻译 5.6

Topic 5.6 Write a program to swap odd and even bits in an integer with as few instructionsn as possible. (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 are swapped, and so on)方法:Mask all odd bi

2013-10-03 15:04:39 510

翻译 5.0

Topic 5.0 General Questionspublic static boolean getBit(int num, int i) { return ((num & (1 << i)) != 0); } public static int setBit(int num, int i) { return num | (1 << i); } publ

2013-10-03 13:52:53 462

翻译 5.5

Topic 5.5 Write a function to determine the number of bits required to convert interger A to interger B.方法1:XOR represents a bit that is different between A and B. Then shift the XOR result.改进:

2013-10-03 13:23:57 486

翻译 5.4

Topic 5.4 Explain what the following code does: ((n&(n-1)==0)1)  If A & B==0, A and B never have a 1 bit in the same place.2)  Subtract 1 from a number: ->If the last bit is 1, impossible

2013-10-01 17:11:34 389

翻译 5.3

Topic 5.3 Given a positive integer, print the next smallest and the next largest number that have the same number of 1 bits in their binary representation.方法1:Brute Force Approach: count the numbe

2013-10-01 17:02:18 521

翻译 5.2

Topic 5.2 Given a real number between 0 and 1(e.g.,0.72) that is passed in as a double, print the binary representation. If the number cannot be represented accurately in binary with at most 32 char

2013-09-30 05:26:17 614

翻译 8.1

Topic 8.1 Design the data structures for a generic deck of cards. Explain how you would subclass the data structures to implement blackjack.public enum Suit { Club (0), Diamond (1), Heart (2

2013-09-29 12:09:59 542

翻译 5.1

Topic 5.1 You are given two 32-bit numbers, N and M, and two bit positions, i and j. Write a method to insert M into N such that M starts at bit j and ends at bit i. You can assume that the bits j t

2013-09-29 11:43:53 495

翻译 4.9

Topic 4.9 You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum to a given value. Note that a path can start or end anywhere in the tree.

2013-09-29 10:53:00 512

翻译 4.8

Topic 4.8 You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1. A tree T2 is a subtree of T1 if th

2013-09-29 05:08:00 539

翻译 4.7

Topic 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 structure. NOTE: This is not necessarily a bina

2013-09-27 16:48:54 461

翻译 4.6

Topic 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 link to its parent.  方法:If n has a ri

2013-09-24 12:17:30 438

翻译 4.5

Topic 4.5:Implement a function to check if a binary tree is a binary search tree.方法0:Do an in-order traversal, copy the elements to an array, check to see if the array is sorted. Takes up a bit of

2013-09-24 09:43:51 436

翻译 6.5

Topic: There is a building of 100 floors. If an egg drops from the Nth floor or above it will break. If it’s dropped from any floor below, it will not break. You’re given 2 eggs. Find N, while minim

2013-09-16 08:33:27 692

翻译 4.4

Topic:Given a binary search tree, design an algortithm which creates a linked list of all the nodes at each depth (e.g. if you have a tree with depth D, you’ll have D linked lists).

2013-09-16 06:11:53 427

翻译 4.3

Topic:Given a sorted (increasing order) array, write an algorithm to create a binary search tree with minimal height.public class TreeNode { public int data; public TreeNode left;

2013-09-16 06:08:36 586

翻译 4.2

Topic:Given a directed graph, design an algorithm to find out whether there is a route between two nodes.// 方法:Do graph traversal, DFS or BFS. Start from one node, and check if the other can be

2013-09-16 05:21:35 532

翻译 4.0

Topic: For Trees, inserInOrder and judge whether isBST  public class TreeNode { public int data; public TreeNode left; public TreeNode right; public TreeNode parent; publ

2013-09-15 10:20:49 438

翻译 4.1

Topic: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 the heights of the two subtrees of any node nev

2013-09-15 10:09:22 548

翻译 3.0

Topic:  Implement a stack & a queue. public class List { Object data; List next; public List(Object d) { this.data = d; this.next = null; } public L

2013-09-10 04:16:00 553

翻译 6.6

Topic: There are one hundred closed lockers in a hallway. A man begins by opening all one hundred lockers. Next, he closes every second locker. Then he goes to every third locker and closes it if it

2013-09-10 02:16:24 591

翻译 6.0

Topic: You have two ropes, and each takes exactly one hour to burn. How would you use them to time exactly 15 minutes? (Ropes are of uneven densities). // Rule 1: Given a rope that takes x minutes t

2013-09-10 01:53:03 598

翻译 6.4

Topic:A bunch of people are living on an island, when a visitor comes with a strange order:all blue-eyed people must leave the island as soon as possible. There will be a flight out at 8:00pm every

2013-09-09 14:50:47 468

翻译 6.3

Topic 6.3 You have a five-quart jug, a three-quart jug, and an unlimited supply of water(but no measuring cups). How would you come up with exactly four quarts of water? Note that the jugs are oddly

2013-09-09 09:50:23 738

翻译 6.2

Topic:  There is an 8*8 chess board in which two diagonally opposite corners have been cut off. You are given 31 dominos, and a single domino can cover exactly two squares. Can you use the 31 dominos

2013-09-09 09:40:51 539

翻译 6.1

Topic: You have 20 bottles of pills. 19 bottles have 1.0 gram pills, but one has pills of weight 1.1 grams. Given a scale that provides an exact measurement, how would you find the heavy bottle? You c

2013-09-09 09:30:47 669

翻译 3.7

Topic

2013-09-06 09:23:20 520

翻译 3.5

Topic

2013-09-06 09:23:14 391

翻译 3.6

Topic

2013-09-06 09:22:44 433

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除