Tag: Remove
Remove Duplicate Elements from a Sorted Singly Linked List
Lets remove all duplicate elements from a sorted singly linked list. For example, Advertisements Suppose given linked list contains following elements in given order, 1, 2, 3, 4, 4, 5, 6, 7, 7, 7, 7, 9, 89 Frequently Asked: Reverse a Singly Linked List in a Single Iteration Create a Singly Linked List from an …
Remove Duplicate Elements from a Sorted Singly Linked ListRead More
Remove all occurences of an element from vector in O(n) complexity
Suppose we have a vector of integers and we want to delete all occurences of a number from it i.e. Let’s say vector contain following numbers 1,2,5,4,5,1,5,7,8,9. Now we want to delete all the occurences of 5 from it, so that vector contents should become – 1 2 4 1 7 8 9 . Also …
Remove all occurences of an element from vector in O(n) complexityRead More
How to remove elements from a List based on value or External Criterion
In this article we will discuss how to remove an element from a List by matching a value or by matching some criterion. std::list provides two member functions for removing elements based on value i.e. std::list::remove and std::list::remove_if. Advertisements Using std::list::remove to remove element by value void remove (const value_type& val); It removes all the elements …
How to remove elements from a List based on value or External CriterionRead More
How to remove elements from a List while Iterating
In this article we will see how to delete an element from a list while iterating through it. Removing Elements From a List while Iterating through it std::list provides a member function erase() that accepts an iterator and deletes the element pointed by that Iterator. But it makes that iterator invalid i.e. we cannot use …
How to Erase / Remove an element from an unordered_map
In this article we will discuss the different ways to remove an element from an unordered_map. Unordered_map provides different overloaded version of erase() member function to delete key value pairs from map. Advertisements Erasing an element from an unordered_map by key Unordered_map provides following overloaded version of erase() that accepts a key by value and …
How to Erase / Remove an element from an unordered_mapRead More
Java : How to Remove elements from HashMap while Iterating
In this article we will discuss different ways to remove elements from HashMap while Iterating. Let’s create a HashMap of String as Key and Integer as value and add some elements into it i.e. Advertisements // Create a HashMap of string and int HashMap<String, Integer> wordFreqMap = new HashMap<>(); // Add elements in Map wordFreqMap.put(“this”, …
Java : How to Remove elements from HashMap while IteratingRead More
How to remove Substrings from a String in C++
In this article we will discuss how to remove single or multiple sub strings from a given string. std::string class provides a member function string::erase() to remove some characters from a given position i.e. Advertisements string& erase (size_t pos = 0, size_t len = npos); It accepts a position and length of characters to be …
Remove key from Dictionary in Python
In this article we will discuss 6 different ways to delete a key from a dictionary in python. Subscribe Table Of Contents Remove a key from a dictionary using dict.pop() Delete a Key from dictionary if exist using pop() Remove a key from a dictionary using items() & for loop Remove a key from a …
Python : How to Remove multiple keys from Dictionary while Iterating ?
In this article we will discuss how to remove multiple key / value pairs from dictionary while iterating. Suppose we have a dictionary of string and int i.e. Advertisements # Dictionary of strings wordFreqDic = { “Hello”: 51, “at” : 23 , “test” : 33, “here” : 63, “start” : 13 } Now we want …
Python : How to Remove multiple keys from Dictionary while Iterating ?Read More
Python : How to Remove Duplicates from a List
In this article we will discuss different ways to remove duplicate elements from a list in python. List : Containing duplicate elements : Advertisements [10, 2, 45, 3, 5, 7, 2, 10, 45, 8, 10] List : After removing duplicate elements, [10, 2, 45, 3, 5, 7, 8] Let’s see how to do that, Frequently …