Hawstein's Blog

Make something people love

Cracking the coding interview--Q12.1

题目 原文: If you were integrating a feed of end of day stock price information ( open, high, low,and closing price) for 5,000 companies, how would you do it? You are responsible for the development...

Cracking the coding interview--Q11.1~Q11.6

题目11.1 原文: Find the mistake(s) in the following code: 1 2 3 unsigned int i; for (i = 100; i <= 0; --i) printf(“%d\n”, i); 解答11.1 简单题。不过不能粗心,否则可能会以为把i <= 0改为i >= 0就OK了。 这就把一个错误改成了另一个...

Cracking the coding interview--Q10.1~Q10.7

题目10.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 shot...

Cracking the coding interview--Q9.7

题目 原文: A circus is designing a tower routine consisting of people standing atop one another’s shoulders. For practical and aesthetic reasons, each person must be both shorter and lighter than t...

Cracking the coding interview--Q9.6

题目 原文: Given a matrix in which each row and each column is sorted, write a method to find an element in it. 译文: 给出一个矩阵,其中每一行和每一列都是有序的,写一个函数在矩阵中找出指定的数。 解答 我们假设这个矩阵每一行都是递增的,每一列也都是递增的,并把这些数据存入文...

Cracking the coding interview--Q9.5

题目 原文: Given a sorted array of strings which is interspersed with empty strings, write a method to find the location of a given string. Example: find “ball” in [“at”, “”, “”, “”, “ball”, “”, “”...

Cracking the coding interview--Q9.4

题目 原文: If you have a 2 GB file with one string per line, which sorting algorithm would you use to sort the file and why? 译文: 如果你有个2GB的文件,其中每一行是一个字符串,你会使用哪种算法来排序,为什么? 解答 当面试官说到2GB文件的时候,他其实就是在...

Cracking the coding interview--Q9.3

题目 原文: Given a sorted array of n integers that has been rotated an unknown number of times, give an O(log n) algorithm that finds an element in the array. You may assume that the array was orig...

Cracking the coding interview--Q9.2

题目 原文: Write a method to sort an array of strings so that all the anagrams are next to each other. 译文: 写一个函数对字符串数组排序,使得所有的变位词都相邻。 解答 首先,要弄清楚什么是变位词。变位词就是组成的字母相同,但顺序不一样的单词。 比如说:live和evil就是一对变位...

Cracking the coding interview--Q9.1

题目 原文: You are given two sorted arrays, A and B, and A has a large enough buffer at the end to hold B. Write a method to merge B into A in sorted order. 译文: A和B是两个有序数组(假设为递增序列),而且A的长度足以放下A和B中...