We are committed to provide service 24 X 7

Deals, Shopping, Training, Tools

Tag: All

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

Finding all values for a key in multimap using equals_range – Example

Multimap store elements in key value pair. It can also have duplicate keys. There can be many scenarios when we want to find all the values associated with a key in multimap. For example, we have a multimap of char & int as key value pair and initialzed with following values i.e. Advertisements {‘a’, 1}, {‘b’, …

Finding all values for a key in multimap using equals_range – ExampleRead More

Find and Replace all occurrences of a sub string in C++

In this article we will discuss how to replace all occurrences of a sub string with new string in C++. For example, we have a string i.e. Advertisements “Boost Library is simple C++ Library” And we want replace all occurrences of ‘Lib’ with XXX. Let’s see the different methods to do it, Frequently Asked: Implementing …

Find and Replace all occurrences of a sub string in C++Read More

Find all occurrences of a sub string in a string | C++ | Both Case Sensitive & InSensitive

In this article we will discuss how to find all occurrences / Positions of a sub string in a given string in both case sensitive & case insensitive manner. Find All Case Sensitive Occurrences of a Sub String in a given String Logic: Use std::string::find to search the first occurrence and then go on searching using …

Find all occurrences of a sub string in a string | C++ | Both Case Sensitive & InSensitiveRead More

C++ : Get the list of all files in a given directory and its sub-directories using Boost & C++17

In this article we will discuss how to fetch the recursive list of all files in a given directory using Boost and C++17 FileSystem Library. Suppose we have a directory i.e. Advertisements /home/user/study/tutorials and I want list of all files in this directory and its sub directories, but also want to skip certain directory like …

C++ : Get the list of all files in a given directory and its sub-directories using Boost & C++17Read More

Java: How to get all keys by a value in HashMap ? | Search by Value in Map

In this article we will discuss how to search into a Map by value and fetch associated keys to the given value. Suppose we have a map of string and integers i.e. Advertisements HashMap<String, Integer> mapOfWords = new HashMap<String, Integer>() { { put(“John”, 25); put(“at”, 2); put(“from”, 10); put(“is”, 5); put(“the”, 2); put(“hello”, 1); put(“break”, …

Java: How to get all keys by a value in HashMap ? | Search by Value in MapRead More

Python : Check if all elements in a List are same or matches a condition

In this article we will dicuss different ways to check if all element in a given List are same or matches a condition. Suppose we have a list of string i.e. Advertisements # List of string listOfStrings = [‘Hello’] * 10 Now let’s use python all() function to check if all elements in the given …

Python : Check if all elements in a List are same or matches a conditionRead More

Python : Check if a list contains all the elements of another list

In this article we will discuss if a list contains all or any elements of another list. Suppose we have have two list i.e. Advertisements # List of string list1 = [‘Hi’ , ‘hello’, ‘at’, ‘this’, ‘there’, ‘from’] # List of string list2 = [‘there’ , ‘hello’, ‘Hi’] Check if list1 contains all elements of …

Python : Check if a list contains all the elements of another listRead More

Python: Iterate / Loop over Dictionary (All key-value pairs)

In this article we will discuss different ways to iterate over all key-value pairs of a dictionary. Table of Contents: Iterate over a dictionary using for loop over keys Iterate over key-value pairs of dictionary using dict.items() Iterate over a dictionary using list comprehension Iterate over specific key-value pairs of dictionary Suppose we have a …

Python: Iterate / Loop over Dictionary (All key-value pairs)Read More

Cart

Your Cart is Empty

Back To Shop