随笔分类 -  CareerCup

摘要:7.5 Given two squares on a two-dimensional plane, find a line that would cut these two squares in half. Assume that the top and the bottom sides of th... 阅读全文
posted @ 2015-09-01 07:05 Grandyang 阅读(888) 评论(0) 推荐(0) 编辑
摘要:7.4 Write methods to implement the multiply, subtract, and divide operations for integers. Use only the add operator.这道题让我们实现乘法加法和除法,而且规定了只能使用加法。那么我们先... 阅读全文
posted @ 2015-08-30 06:06 Grandyang 阅读(1036) 评论(0) 推荐(0) 编辑
摘要:7.3 Given two lines on a Cartesian plane, determine whether the two lines would intersect.这道题说是在笛卡尔坐标系中,让我们确定两条直线是否相交。那么我们首先要写个直线的类来表示直线,最常见的表示方法为y=kx... 阅读全文
posted @ 2015-08-29 06:43 Grandyang 阅读(1054) 评论(0) 推荐(0) 编辑
摘要: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 walk... 阅读全文
posted @ 2015-08-28 10:55 Grandyang 阅读(916) 评论(0) 推荐(0) 编辑
摘要:7.1 You have a basketball hoop and someone says that you can play one of two games.Game 1: You get one shot to make the hoop.Game 2: You get three sho... 阅读全文
posted @ 2015-08-28 10:26 Grandyang 阅读(794) 评论(0) 推荐(0) 编辑
摘要:6.6 There are 100 closed lockers in a hallway. A man begins by opening all 100 lockers. Next, he closes every second locker. Then, on his third pass, ... 阅读全文
posted @ 2015-08-27 11:53 Grandyang 阅读(1303) 评论(0) 推荐(0) 编辑
摘要:6.5 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 b... 阅读全文
posted @ 2015-08-27 11:14 Grandyang 阅读(4209) 评论(1) 推荐(0) 编辑
摘要:6.4 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 possib... 阅读全文
posted @ 2015-08-24 06:59 Grandyang 阅读(1188) 评论(0) 推荐(0) 编辑
摘要: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 qu... 阅读全文
posted @ 2015-08-24 06:28 Grandyang 阅读(1036) 评论(0) 推荐(0) 编辑
摘要:6.2 There is an 8x8 chess board in which two diagonally opposite corners have been cut off. You are given 31 dominos, and a single domino can cover ex... 阅读全文
posted @ 2015-08-24 06:13 Grandyang 阅读(779) 评论(0) 推荐(0) 编辑
摘要:6.1 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 measurem... 阅读全文
posted @ 2015-08-24 04:57 Grandyang 阅读(652) 评论(0) 推荐(0) 编辑
摘要: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 阅读全文
posted @ 2015-08-23 10:51 Grandyang 阅读(1036) 评论(0) 推荐(0) 编辑
摘要: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... 阅读全文
posted @ 2015-08-21 11:42 Grandyang 阅读(2159) 评论(0) 推荐(0) 编辑
摘要:5.6 Write a program to swap odd and even bits in an integer with as few instructions as possible (e.g., bit 0 and bit 1 are swapped, bit 2 and bit 3 a... 阅读全文
posted @ 2015-08-20 06:56 Grandyang 阅读(1202) 评论(0) 推荐(0) 编辑
摘要:5.5 Write a function to determine the number of bits required to convert integer A to integer B.EXAMPLEInput: 31,14Output: 2 这道题给了我们两个数字A和B,问如果将A转化为B需 阅读全文
posted @ 2015-08-14 15:54 Grandyang 阅读(639) 评论(0) 推荐(0) 编辑
摘要:5.4 Explain what the following code does: ((n & (n-1)) == 0).这道题让我们解释一个表达式((n & (n-1)) == 0),是说一个数跟比它小1的数字按位相与,结果全是0的情况,那么说明两个数每个位置上至少都有一个0,那么最有可能的情况是... 阅读全文
posted @ 2015-08-13 22:33 Grandyang 阅读(718) 评论(0) 推荐(0) 编辑
摘要: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. 阅读全文
posted @ 2015-08-12 21:12 Grandyang 阅读(583) 评论(0) 推荐(0) 编辑
摘要: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 represent... 阅读全文
posted @ 2015-08-11 15:02 Grandyang 阅读(771) 评论(0) 推荐(0) 编辑
摘要:5.1 You are given two 32-bit numbers, N and M, and two bit positions, land j. Write a method to insert M into N such that M starts at bit j and ends a... 阅读全文
posted @ 2015-08-10 09:05 Grandyang 阅读(803) 评论(0) 推荐(0) 编辑
摘要: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. The path does 阅读全文
posted @ 2015-08-09 10:05 Grandyang 阅读(1104) 评论(3) 推荐(0) 编辑

Fork me on GitHub