Loading...
「ツール」は右上に移動しました。
利用したサーバー: natural-voltaic-titanium
28いいね 914回再生

Addition of two linked lists. (Data Structures and Algorithms #34)(Linked List #8)

This video explains how to add two linked lists representing numbers. Program should return the addition of two linked list in form of linked list. There are many follow ups to this question. Below are the follow ups that are usually asked in interviews:

1.) You can modify the linkedlist. So, basically you can reverse the linked list and solve this problem easily.
2.) Follow up: You can not modify the linked list. So, now you can not reverse the linkedlist. We have discussed the recursive solution to solve this problem. The drawback of using recursion is that recursion tries to load the whole list into memory. So, if the linked list is very big (containing billion nodes), program can crash.
3.) Follow up: When linked list can not be loaded into main memory like we discussed in point 2. This constraint takes this problem to another new level. Mostly interviewer use this follow up to understand candidate's understanding of the domain. This solution is not discussed in this video and will be discussed in another video.

Recursive solution:
Time Complexity: O(n)
Space Complexity: O(n)

Code Repository Link: github.com/HimanshuVerma18111989/Code-Campaign
Recursion Playlist:    • Master Recursion Backtracking Interview Qu...…

コメント