Blogs Hub

by AskGif | Sep 30, 2020 | Category :coding

Convert Binary Number in a Linked List to Integer - Linked List - Easy - LeetCode

Convert Binary Number in a Linked List to Integer - Linked List - Easy - LeetCode

Given head which is a reference node to a singly-linked list. The value of each node in the linked list is either 0 or 1. The linked list holds the binary representation of a number. Return the decimal value of the number in the linked list. &nbsp; Example 1: <br />Inp

read more...

by AskGif | Sep 30, 2020 | Category :coding

Middle of the Linked List - Linked List - Easy - LeetCode

Middle of the Linked List - Linked List - Easy - LeetCode

Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. &nbsp; Example 1: Input: [1,2,3,4,5]<br />Output: Node 3 from this list (Serialization: [3,4,5])<br />The retur

read more...

by AskGif | Sep 30, 2020 | Category :coding

Delete Node in a Linked List - Linked List - Easy - LeetCode

Delete Node in a Linked List - Linked List - Easy - LeetCode

Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list. &nbsp; Example 1:

read more...

by AskGif | Sep 30, 2020 | Category :coding

Palindrome Linked List - Linked List - Easy - LeetCode

Palindrome Linked List - Linked List - Easy - LeetCode

Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1-&gt;2<br />Output: false<br />Example 2: Input: 1-&gt;2-&gt;2-&gt;1<br />Output: true<br />Follow up:<br />Could you do it in O(n) time and O(1) space? <pre class="language-csharp"><code>/**

read more...

by AskGif | Sep 30, 2020 | Category :coding

Remove Linked List Elements - Linked List - Easy - LeetCode

Remove Linked List Elements - Linked List - Easy - LeetCode

Remove all elements from a linked list of integers that have value val. Example: Input: &nbsp;1-&gt;2-&gt;6-&gt;3-&gt;4-&gt;5-&gt;6, val = 6<br />Output: 1-&gt;2-&gt;3-&gt;4-&gt;5 <pre class="language-csharp"><code>/** * Definition for singly-linked list. * public class ListNo

read more...

by AskGif | Sep 30, 2020 | Category :coding

Intersection of Two Linked Lists - Linked List - Easy - LeetCode

Intersection of Two Linked Lists - Linked List - Easy - LeetCode

Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: <br />begin to intersect at node c1. &nbsp; Example 1: <br />Input: intersectVal = 8, listA = [4,1,8,4,5], listB = [5,6,1,8

read more...

by AskGif | Sep 30, 2020 | Category :coding

Linked List Cycle - Linked List - Easy - LeetCode

Linked List Cycle - Linked List - Easy - LeetCode

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 continuously following the next pointer. Internally, pos is used to denote the index of the node that tail

read more...

by AskGif | Sep 30, 2020 | Category :coding

Remove Duplicates from Sorted List - Linked List - Easy - LeetCode

Remove Duplicates from Sorted List - Linked List - Easy - LeetCode

Given a sorted linked list, delete all duplicates such that each element appear only once. Example 1: Input: 1-&gt;1-&gt;2<br />Output: 1-&gt;2<br />Example 2: Input: 1-&gt;1-&gt;2-&gt;3-&gt;3<br />Output: 1-&gt;2-&gt;3 <pre class="language-csharp"><code>/** * Definition

read more...

by AskGif | Sep 30, 2020 | Category :coding

Merge Two Sorted Lists - Linked List - Easy - LeetCode

Merge Two Sorted Lists - Linked List - Easy - LeetCode

Merge two sorted linked lists and return it as a new sorted list. The new list should be made by splicing together the nodes of the first two lists. Example: Input: 1-&gt;2-&gt;4, 1-&gt;3-&gt;4<br />Output: 1-&gt;1-&gt;2-&gt;3-&gt;4-&gt;4 <pre class="language-csharp"><code>/**

read more...

by AskGif | Aug 08, 2018 | Category :coding

What is a Linked List?

What is a Linked List?

A linked list is a data structure used for storing collections of data. A linked list has the following properties. - Successive elements are connected by pointers - The last element points to NULL - Can grow or shrink in size during execution of a program - Can be

read more...

by AskGif | Aug 07, 2018 | Category :coding

Given two sorted Linked Lists, we need to merge them into the third list in sorted order.

Given two sorted Linked Lists, we need to merge them into the third list in sorted order.

We are Given two Linked Lists which are already sorted. We need to create a new linked list using these two linked lists and it is required to be in sorted order. One way we can do is to append second string in the first one and then will apply quick sort which will be having a time complexity of

read more...

by AskGif | Aug 07, 2018 | Category :coding

Check whether the given Linked List length is even or odd?

Check whether the given Linked List length is even or odd?

The question is to find if the given linked list length is even or odd in optimum time. We will use a&nbsp;fast pointer, i.e 2x pointer. the fast pointer moves two nodes at a time. In the end, we will either be having the node as Null or the Node will be the last node in the Linked list. if the n

read more...