Found 33676 Articles for Programming

Check if all people can vote on two machines in Python

Arnab Chakraborty
Updated on 30-Dec-2020 12:33:20

136 Views

Suppose we have a number n denotes n people and there are two identical voting machines. We also have an array called time of size n such that time[i] represents total time spent by i-th person to vote on any machine. At one time instant, only one person can be there on each of the two machines. We also have another value x, representing the maximum allowable time for which machines are operational, we have to check whether all persons can place their vote or not.So, if the input is like n = 3, x = 7, time = [3, ... Read More

Delete alternate nodes of a Linked List in C++

Hafeezul Kareem
Updated on 30-Dec-2020 07:01:21

1K+ Views

In this tutorial, we are going to learn how to delete all prime nodes from a singly linked list.Let's see the steps to solve the problem.Write struct with data and next pointer.Write a function to insert the node into the singly linked list.Initialize the singly linked list with dummy data.Iterate over the singly linked list.Delete alternate node by maintaining the previous node.Write a function to delete the node. Consider the following three cases while deleting the node.If the node is head node, then move the head to next node.If the node is middle node, then link the next node to ... Read More

Delete all the nodes from the list that are greater than x in C++

Hafeezul Kareem
Updated on 30-Dec-2020 06:59:33

2K+ Views

In this tutorial, we are going to learn how to delete all prime nodes from a singly linked list.Let's see the steps to solve the problem.Write struct with data and next pointer.Write a function to insert the node into the singly linked list.Initialize the singly linked list with dummy data.Iterate over the singly linked list. Find whether the current node data is greater than x or not.If the current data is greater than x, then delete the node.Write a function to delete the node. Consider the following three cases while deleting the node.If the node is head node, then move ... Read More

Delete all the nodes from the doubly linked list that are greater than a given value in C++

Hafeezul Kareem
Updated on 30-Dec-2020 06:57:36

158 Views

In this tutorial, we are going to learn how to delete all prime nodes from a doubly linked list.Let's see the steps to solve the problem.Write struct with data, prev and next pointers.Write a function to insert the node into the doubly linked list.Initialize the doubly linked list with dummy data.Iterate over the doubly linked list. Find whether the current node data is greater than given value or not.If the current data is greater than the given value, then delete the node.Write a function to delete the node. Consider the following three cases while deleting the node.If the node is ... Read More

Delete all the nodes from a doubly linked list that are smaller than a given value in C++

Hafeezul Kareem
Updated on 30-Dec-2020 06:55:49

271 Views

In this tutorial, we are going to learn how to delete all prime nodes from a doubly linked list.Let's see the steps to solve the problem.Write struct with data, prev and next pointers.Write a function to insert the node into the doubly linked list.Initialize the doubly linked list with dummy data.Iterate over the doubly linked list. Find whether the current node data is less than given value or not.If the current data is less than the given value, then delete the node.Write a function to delete the node. Consider the following three cases while deleting the node.If the node is ... Read More

Delete all the even nodes from a Doubly Linked List in C++

Hafeezul Kareem
Updated on 30-Dec-2020 06:53:58

899 Views

In this tutorial, we are going to learn how to delete all prime nodes from a doubly linked list.Let's see the steps to solve the problem.Write struct with data, prev and next pointers.Write a function to insert the node into the doubly linked list.Initialize the doubly linked list with dummy data.Iterate over the doubly linked list. Find whether the current node data is even or not.If the current data is even, then delete the node.Write a function to delete the node. Consider the following three cases while deleting the node.If the node is head node, then move the head to ... Read More

Delete all Prime Nodes from a Singly Linked List in C++

Hafeezul Kareem
Updated on 30-Dec-2020 06:51:52

525 Views

In this tutorial, we are going to learn how to delete all prime nodes from a singly linked list.Let's see the steps to solve the problem.Write struct with data and next pointer.Write a function to insert the node into the singly linked list.Initialize the singly linked list with dummy data.Iterate over the singly linked list. Find whether the current node data is prime or not.If the current data is prime, then delete the node.Write a function to delete the node. Consider the following three cases while deleting the node.If the node is head node, then move the head to next ... Read More

Delete all Prime Nodes from a Doubly Linked List in C++

Hafeezul Kareem
Updated on 30-Dec-2020 06:49:35

205 Views

In this tutorial, we are going to learn how to delete all prime nodes from a doubly linked list.Let's see the steps to solve the problem.Write struct with data, prev and next pointers.Write a function to insert the node into the doubly linked list.Initialize the doubly linked list with dummy data.Iterate over the doubly linked list. Find whether the current node data is prime or not.If the current data is prime, then delete the node.Write a function to delete the node. Consider the following three cases while deleting the node.If the node is head node, then move the head to ... Read More

Delete all Non-Prime Nodes from a Singly Linked List in C++

Hafeezul Kareem
Updated on 30-Dec-2020 06:47:16

160 Views

In this tutorial, we are going to learn how to delete all prime nodes from a singly linked list.Let's see the steps to solve the problem.Write struct with data and next pointer.Write a function to insert the node into the singly linked list.Initialize the singly linked list with dummy data.Iterate over the singly linked list. Find whether the current node data is prime or not.If the current data is not prime, then delete the node.Write a function to delete the node. Consider the following three cases while deleting the node.If the node is head node, then move the head to ... Read More

Delete a node in a Doubly Linked List in C++

Hafeezul Kareem
Updated on 03-Dec-2024 09:41:31

7K+ Views

In this tutorial, we are going to learn how to delete a node in the doubly linked list. Approach Let's see the steps to solve the problem. Write struct with data, prev, and next pointers. Write a function to insert the node into the doubly linked list. Initialize the doubly ... Read More

Advertisements