AlexLintu
  • Home
  • JavaScript
  • HackerRank
  • Concepts
Subscribe
Tagged

Linked Lists

A collection of 3 posts

HackerRank Delete a Node from a Linked List | JS Solution
Linked Lists

HackerRank Delete a Node from a Linked List | JS Solution

ProblemHackerRank detailed problem description can be found here. Inputs & Outputs/* param {Node} head param {number} position return {Node} head */Test CaseInitial Linked ListResulting Linked ListJavaScript Solutionfunction deleteNode(head, position) { if (!head) { return null; } let nodeToDelete = head; if (position === 0) { head = nodeToDelete.next; return head; } let count = 0; let prev

  • AlexLintu
AlexLintu Mar 21, 2021 • 1 min read
Linked List Cycle Detection | JS Solution
JavaScript

Linked List Cycle Detection | JS Solution

HackerRank detailed problem description can be found here. ProblemDetermine if a provided singly linked list has a cycle in it, meaning if any node is visited more than once while traversing the list. Inputs & Outputs/* param {Node} head return {number} 1 or 0 */Codefunction hasCycle(head) { if (!head) { return

  • AlexLintu
AlexLintu Mar 20, 2021 • 1 min read
HackerRank Insert a Node at a Specific Position in a Linked List | JS Solution
HackerRank

HackerRank Insert a Node at a Specific Position in a Linked List | JS Solution

ProblemHackerRank detailed problem description can be found here. We need to create a function insertNodeAtPosition(head, data, position) {}. This function should: Create a new node using provided dataInsert that newly created node at the provided position inside a Singly Linked ListLastly, return the head nodeInputs & Outputs/* param {Node} head

  • AlexLintu
AlexLintu Mar 19, 2021 • 1 min read
AlexLintu © 2022
  • GitHub
Powered by Ghost