Unofficial C Solution to Problem 2.1 in Cracking the Coding Interview (5th Edition)

16 Apr

There are two solutions for this question. The first one is with hash table, thus needs more space but less time. The second one needs no additional space but more time. In the first solution, I choose to use the … Read More »

Unofficial C Solution to Problem 1.8 in Cracking the Coding Interview (5th Edition)

12 Apr

If string str1 is a rotation of string str2, it must holds two conditions: The length of str1 equals to the length of str2; There is at least a set of two string A and B, such that str1=AB and … Read More »

Unofficial C Solution to Problem 1.7 in Cracking the Coding Interview (5th Edition)

23 Mar

In this question, we have to travel the matrix twice. In the first time, we need to record which rows and columns contain zero element. And in the second round, we will set these rows and columns entirely zero. By … Read More »

Unofficial C Solution to Problem 1.6 in Cracking the Coding Interview (5th Edition)

22 Mar

This question asks us to rotate an N by N matrix. Each element in the matrix is a pixel of an image, and represented by 4 bytes. The question did not indicate the length of byte. And I assume the … Read More »

Unofficial C Solution to Problem 1.5 in Cracking the Coding Interview (5th Edition)

20 Mar

Generally, this question requires us to do a length encoding of an string. For example, after compression, the string “aaaabb” should become “a4b2”. If the compression could not shorten the string, the program will leave original string unchanged. I solve … Read More »

9 Feb

5 Feb

3 Feb

Unofficial C Solution to Problem 1.1 in Cracking the Coding Interview (5th Edition)

2 Feb

WIith Google search, I find there is a website (http://crack5e.info/) to list the C++ solutions to the problems listed in book Cracking the Coding Interview (5th edition). It is a great website. Thanks to the author! In the following days, … Read More »