Closed sinhaaman closed 6 years ago
@sinhaaman Do you have the questions from the new version of the Cracking the coding interview book?
Problem 2.1. a) method CTCIprob21a(); Problem 2.1. b) If a temporary buffer is not allowed, then I will have a double loop, I will keep one pointer at the beginning of the linked list (first element) and run one loop and the second pointer with the second loop with the second element and I will move the pointer until the end of the loop. CTCIprob21b(); Return the kth element from the back- CTCIprob22(int k){
@emmcold yes, I have the new version of the book (version 6). I was looking at your commits for example, f468bae1b097f85e6adcb1de8fe883a39ed010bd . Can you please check comments on that commit?
@sinhaaman I need help with the problem 2.4 I don't understand it. :(
@sinhaaman I need help with this; /**
There is no need to reverse the linked list. You have to add the linked list in the forward direction.
@sinhaaman will my ideas of reverse work? And if not, why?
p.s. @sinhaaman I don't understand your algo up. :(
@sinhaaman can you check the other solutions from the cracking the coding interview.
Currently 2 problems are unsolved there:
@EmiraZiberi yes, your ideas will work for the forward sum problem.
In question number 2.4, it says that you are given a linked list. 3 -> 10 -> 6 -> 1 -> 7 -> 20 ->5 ->NULL
and you are given an integer n. You need to partition the linked list in such a manner that the first part contains the elements less than n. e.g. consider the two partition around n=5 3 -> 1 -> NULL (Linked List having elements less than 5) LIST 1 10 -> 6 -> 7 -> 20 -> 5 ->NULL (Liked List having elements greater than or equal to 5). LIST 2
Now let's append LIST 2 to LIST 1 we get: 3 -> 1 -> 10 -> 6 -> 7 -> 20 -> 5 ->NULL
This is the expected result from your code.
Let me know if you need more explanation.
@sinhaaman then why should i use the approaches you mentioned earlier? :grin:
The solution is: * Solution: Reverse the two linked list and use the above approach.
Solve all questions on CTCI. DON'T Skip any.