Mark As Completed Discussion

Good morning! Here's our prompt for today.

Assume you have a Linked List implementation that has the following API:

JAVASCRIPT
1// prepend to start of list
2#prepend(val);
3
4// appends to end of list
5#append(val);
6
7// get an array of node values (for testing)
8#toArray();

Can you write a method getIntersection(list1, list2) to find the intersection of two linked lists?

Description

The return value should be a new linked list.

Constraints

  • Length of the two linked lists <= 1000
  • The nodes in the list will always contain integer values between -1000000000 and 1000000000
  • Expected time complexity : O(n*m) (the lengths of the two lists)
  • Expected space complexity : O(n)

Try to solve this here or in Interactive Mode.

How do I practice this challenge?

JAVASCRIPT
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment

We'll now take you through what you need to know.

How do I use this guide?

Access all course materials today

The rest of this tutorial's contents are only available for premium members. Please explore your options at the link below.

Returning members can login to stop seeing this.