Created
February 21, 2021 19:06
-
-
Save szinck1/74c85945510be26e85caeb4c19f90599 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListNode { | |
constructor(data) { | |
this.data = data | |
this.next = null | |
} | |
} | |
class LinkedList { | |
constructor(head = null) { | |
this.head = head | |
} | |
} | |
let node1 = new ListNode(2) | |
let node2 = new ListNode(5) | |
node1.next = node2 | |
var list = new LinkedList(node1) | |
function searchLL(list, item) { | |
var temp = list.head; | |
while (temp !== null) { | |
if(temp.data === item) { | |
return true; | |
} | |
temp = temp.next; | |
} | |
return false | |
} | |
searchLL(list, 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment