AlexLintu

AlexLintu

Thoughts, stories and ideas.

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

HackerRank Delete a Node from a Linked List | JS Solution

Problem HackerRank detailed problem description can be found here [https://www.hackerrank.com/challenges/delete-a-node-from-a-linked-list/problem] . Inputs & Outputs /* param {Node} head param {number} position return {Node} head */ Test Case Initial Linked ListResulting Linked ListJavaScript Solution function deleteNode(head, position) { if (!head) { return null; } let nodeToDelete = head; if (position === 0)
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

Problem HackerRank detailed problem description can be found here [https://www.hackerrank.com/challenges/insert-a-node-at-a-specific-position-in-a-linked-list/problem] . We need to create a function insertNodeAtPosition(head, data, position) {}. This function should: * Create a new node using provided data * Insert that newly created node at the provided position inside a Singly Linked List
1 min read