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

9 May

The official solution for the backward problem is quite good. In contrast, there are two improvable places in the official solution for the forward problem (the follow up question). On one hand, in the official implement, the list is double … Read More »

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

25 Apr

The question is one step in the quick sort algorithm. The idea is to rearrange the list so that the smaller nodes than pivot are previous to all other nodes. More details could be found on Wikipedia. In the implements … Read More »

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

21 Apr

The description of this question is not quite clear. What does “given only access to that node” exactly mean? If we cannot read any other node, it is impossible to finish the work. If we could only read the node, … Read More »

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

20 Apr

In the book, the author introduces many different methods. As the author indicates, the two-pointer iterative solution is the best. In contrast, the recursive method is less effective but quite interesting. It might be useful in some cases. I only … Read More »

## 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 »

## Find a Duplicate Item In an Array of Shuffled Consecutive Integers

16 Mar

Question: if you hava an array with n integers. These integers are in random order. And each interger is between 1 and n-1, including 1 and n-1. Additionally, there is one and only one integer, which appears twice, while all … Read More »