VehiclesFashionRecipesBlogsHuntTravelsSportFunHandmadeITEducation
Mini-Games
x

x
zakruti.com » IT - Software » freeCodeCamp.org
Linked Lists for Technical Interviews - Full Course

Linked Lists for Technical Interviews - Full Course

FBTwitterReddit

video description

Rating: 4.0; Vote: 1
Learn how to solve linked list problems for coding challenges and interviews Wang: for zipper linked lists, I think this approach maybe simpler to understand
---
const zipperLinkedListsIterative = (h1, h2) => -
let cur1 = h1;
let cur2 = h2;
let next1;
let next2;
while(cur2 !== null && cur1 !== null)-
next1 = cur1.next;
next2 = cur2.next;
cur1.next = cur2;
cur2.next = next1;
cur2 = next2;
cur1 = next1;
-
if (cur2 !== null) cur1.next = cur2;
return h1;
-
const zipperLinkedListsRecursive = (h1, h2, cur1 = h1, cur2 = h2) => -
if (!cur1) -
cur1 = cur2;
return h1;
-
if (!cur2) return h1;
let next1 = cur1.next;
let next2 = cur2.next;
cur1.next = cur2;
cur2.next = next1;
return zipperLinkedListsRecursive(h1, h2, next1, next2);
-
---

Date: 2022-03-14

Comments and reviews: 9


I added a few cool touches to the sum problem:
def get_sum_of_list(self):-
sum = 0-
current = self.head-
while current is not None:-
if type(current.data) is int or float:-
sum += current.data-
current = current.next-
return sum-
def get_combined_strings(self):-
res = ---
current = self.head-
while current is not None:-
if type(current.data) is str:-
res += current.data-
current = current.next-
return res

reply

Hey, what do you think about this solution for -Zipper Lists-?
const zipperLists = (head1, head2) => --
let current1 = head1;-
let current2 = head2;-
let next1, next2;
while (current1 !== null && current2 !== null) --
next1 = current1.next;-
next2 = current2.next;-
current1.next = current2;
if (next1 !== null)
current2.next = next1
current1 = next1;-
current2 = next2;-
--
return head1-
-;

reply

function zipper(head1: ListNode, head2: ListNode) --
let current1: ListNode - null = head1-
let current2: ListNode - null = head2-
while (current1 && current2) --
let next1: ListNode - null = current1.next;-
let next2: ListNode - null = current2.next-
current1.next = current2-
if (next1) current2.next = next1-
current1 = next1-
current2 = next2-
--
-

reply

Thank you so much for the course , as always it's awesome!
Can somebody help me please and explain if instead of creating variable -currentHead- inside the function we'll just work with argument -head- and inside while loop just write -head = head.next-
It's working in both cases but I want to see if it's any downside in this approach or something like that.
Thanks in advance !

reply

Realy nice teaching style. Just one question. - 37:00 it says the space is O(n) for the recursive sumList function. That is true for how it is implemented. But couldn't we also achieve O(1) by passing the sum variable into every recursion like it's done with the recursive linkedListValues? Wouldn't hat be much more optimised?
reply

The best I have seen so far...Thank you so much... I just checked your platform to make a purchase to go deeper but I couldn't find C# language option (that's my core language).
I don't know if there will be room for that in the future?
I greatly benefited from this JavaScript version.

reply

I wish you had Java as one of the programming languages, but I still loved your course and was able to interpret everything in Java because of how you explained the algorithms, it was so simple to even understand recursive, something I always mess up. Thank you!!
reply

in the zipper list problem in the iterative solution shouldn't the condition be ...while(current1 != NULL -- current2 != NULL) instead of while(current1 != NULL && current2 != NULL) ?
would be really helpful if someone could answer. TIA

reply

Hey Programmers! Thanks for watching. If you enjoy my teaching, be sure to check out my platform Structy for more data structures and algorithms (link in description). Cheers!
-Alvin

reply
Add a review, comment






Other channel videos