Leetcode 0426. Convert Binary Search Tree to Sorted Doubly Linked List

Posted on Thu 12 December 2024 in Leetcode Premium • Tagged with linked-list

Question Link : https://leetcode.com/problems/convert-binary-search-tree-to-sorted-doubly-linked-list/

Difficulty: Medium

Premium: True

Question

Convert a Binary Search Tree to a sorted Circular Doubly-Linked List in place. You can think of the left and right pointers as synonymous to the predecessor and successor pointers in a doubly-linked list. For a circular doubly …


Continue reading

Leetcode 0019. Remove Nth Node From End of List

Posted on Mon 02 December 2024 in Leetcode • Tagged with linked-list, two-pointers, trailing-pointer

Question Link : https://leetcode.com/problems/remove-nth-node-from-end-of-list/

Difficulty: Medium

Premium: False

Question

Given the head of a linked list, remove the nth node from the end of the list and return its head.   Example 1:

Input: head = [1,2,3,4,5], n = 2 Output: [1,2,3,5]

Example …


Continue reading

Leetcode 3263. Convert Doubly Linked List to Array I

Posted on Fri 22 November 2024 in Leetcode Premium • Tagged with linked-list

Question Link : https://leetcode.com/problems/convert-doubly-linked-list-to-array-i/

Difficulty: Easy

Premium: True

Question

You are given the head of a doubly linked list, which contains nodes that have a next pointer and a previous pointer. Return an integer array which contains the elements of the linked list in order.   Example 1 …


Continue reading

Leetcode 0002. Add Two Numbers

Posted on Sun 27 November 2022 in Leetcode • Tagged with linked-list, dummy-list-head

Question Link : https://leetcode.com/problems/add-two-numbers/

Difficulty: Medium

Premium: False

Question

You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order, and each of their nodes contains a single digit. Add the two numbers and return the sum as a linked …


Continue reading

Leetcode 0206. Reverse Linked List

Posted on Mon 31 October 2022 in Leetcode • Tagged with linked-list

Question Link : https://leetcode.com/problems/reverse-linked-list/

Difficulty: Easy

Question

Given the head of a singly linked list, reverse the list, and return the reversed list.   Example 1:

Input: head = [1,2,3,4,5] Output: [5,4,3,2,1]

Example 2:

Input: head = [1,2] Output: [2,1 …


Continue reading

Leetcode 0160. Intersection of Two Linked Lists

Posted on Sun 16 October 2022 in Leetcode • Tagged with linked-list

Question Link : https://leetcode.com/problems/intersection-of-two-linked-lists/

Difficulty: Easy

Question

Given the heads of two singly linked-lists headA and headB, return the node at which the two lists intersect. If the two linked lists have no intersection at all, return null. For example, the following two linked lists begin to …


Continue reading

Leetcode 0138. Copy List with Random Pointer

Posted on Fri 11 March 2022 in Leetcode • Tagged with linked-list, dummy-list-head, recursion

Question Link : https://leetcode.com/problems/copy-list-with-random-pointer/

Difficulty: Medium

Question

A linked list of length n is given such that each node contains an additional random pointer, which could point to any node in the list, or null. Construct a deep copy of the list. The deep copy should consist …


Continue reading

Leetcode 0061. Rotate List

Posted on Thu 10 March 2022 in Leetcode • Tagged with linked-list, list-to-ring

Question Link : https://leetcode.com/problems/rotate-list/

Difficulty: Medium

Question

Given the head of a linked list, rotate the list to the right by k places.   Example 1:

Input: head = [1,2,3,4,5], k = 2 Output: [4,5,1,2,3]

Example 2:

Input: head = [0,1,2 …


Continue reading

Leetcode 0141. Linked List Cycle

Posted on Mon 07 March 2022 in Leetcode • Tagged with linked-list, fast-slow-pointer

Question Link : https://leetcode.com/problems/linked-list-cycle/

Difficulty: Easy

Question

Given head, the head of a linked list, determine if the linked list has a cycle in it. There is a cycle in a linked list if there is some node in the list that can be reached again by …


Continue reading

Leetcode 0021. Merge Two Sorted Lists

Posted on Sun 06 March 2022 in Leetcode • Tagged with linked-list

Question Link : https://leetcode.com/problems/merge-two-sorted-lists/

Difficulty: Easy

Question

You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head …


Continue reading