01.09.2019»»воскресенье

Cracking The Coding Interview 6th Edition

01.09.2019
    58 - Comments

The question is return the kth to last element of a singly linked list. All the proposed solutions are pretty complex, and I don't know why my solution is invalid. Could someone please let me know why?

  1. Cracking The Coding Interview 7th Edition Pdf
  2. Cracking The Coding Interview 6th Edition Filetype Epub

Now in the 6th edition, the book gives you the interview preparation you need to get the top software developer jobs. This is a deeply technical book and focuses. Cracking the Coding Interview, 6th Edition is here to help you through this process, teaching you what you need to know and enabling you to perform at your very best. I’ve coached and interviewed hundreds of software engineers. The result is this book. Cracking the Coding Interview 6th Ed. Contribute to careercup/CtCI-6th-Edition development by creating an account on GitHub.

mkobit
23.5k6 gold badges95 silver badges110 bronze badges
segue_segwaysegue_segwayCracking The Coding Interview 6th Edition
7051 gold badge9 silver badges25 bronze badges

3 Answers

A singly linked list would not have both next and previous. You have a doubly linked list, which clearly makes this problem easier.

ZongZong
5,0735 gold badges23 silver badges39 bronze badges

I don't have a copy of that book, so I don't know what complicated solutions might be found in it, but the following two-finger solution seems pretty simple to me, and is not that different from yours aside from using a singly-linked list: Fifa 10 setup.exe download.

riciCracking the coding interview 6th edition pdf free downloadrici
163k22 gold badges145 silver badges212 bronze badges

The first solution in the book says:

Solution #1: If linked list size is known

If the size of the linked list is known, then the kth to last element is the (length - k)th element. We can just iterate through the linked list to find this element. Because this solution is so trivial, we can almost be sure that this is not what the interviewer intended.

Cracking The Coding Interview 7th Edition Pdf

But we can easily find the size of the linked list by one pass! So modifying the OP's question, I ask what is wrong with the following answer?

We use two pointers. Use one to find the size of the linked list, and use the other one to go (size - k) steps.

(Implementation in Python)

LoMaPhLoMaPh

Cracking The Coding Interview 6th Edition Filetype Epub

3511 gold badge7 silver badges18 bronze badges

Not the answer you're looking for? Browse other questions tagged javaalgorithmlinked-list or ask your own question.