Found 7197 Articles for C++

multimap rbegin in C++ STL

Sunidhi Bansal
Updated on 22-Apr-2020 11:34:40

201 Views

In this article we will be discussing the working, syntax, and examples of multimap::rbegin() function in C++ STL.What is Multimap in C++ STL?Multimaps are the associative containers, which are similar to map containers. It also facilitates to store the elements formed by a combination of key-value and mapped value in a specific order. In a multimap container, there can be multiple elements associated with the same key. The data is internally always sorted with the help of its associated keys.What is multimap::rbegin()?multimap::rbegin() function is an inbuilt function in C++ STL, which is defined in header file. rbegin() implies reverse ... Read More

multimap rend in C++ STL

Sunidhi Bansal
Updated on 22-Apr-2020 11:32:48

160 Views

In this article we will be discussing the working, syntax, and examples of multimap::rend() function in C++ STL.What is Multimap in C++ STL?Multimaps are the associative containers, which are similar to map containers. It also facilitates to store the elements formed by a combination of key-value and mapped value in a specific order. In a multimap container, there can be multiple elements associated with the same key. The data is internally always sorted with the help of its associated keys.What is multimap::rend()?multimap::rend() function is an inbuilt function in C++ STL, which is defined in  header file. rend() implies reverse end ... Read More

multimap::begin() and multimap::end() in C++ STL

Sunidhi Bansal
Updated on 22-Apr-2020 11:31:33

494 Views

In this article we will be discussing the working, syntax, and examples of multimap::begin() and multimap::end() functions in C++ STL.What is Multimap in C++ STL?Multimaps are the associative containers, which are similar to map containers. It also facilitates storing the elements formed by a combination of key-value and mapped value in a specific order. In a multimap container, there can be multiple elements associated with the same key. The data is internally always sorted with the help of its associated keys.What is multimap::begin()?multimap::begin() function is an inbuilt function in C++ STL, which is defined in header file. begin() is ... Read More

multimap::erase() in C++ STL

Sunidhi Bansal
Updated on 22-Apr-2020 11:28:03

2K+ Views

In this article we will be discussing the working, syntax, and examples of multimap::erase() function in C++ STL.What is Multimap in C++ STL?Multimaps are the associative containers, which are similar to map containers. It also facilitates storing the elements formed by a combination of key-value and mapped value in a specific order. In a multimap container, there can be multiple elements associated with the same key. The data is internally always sorted with the help of its associated keys.What is multimap::erase()?multimap::erase() function is an inbuilt function in C++ STL, which is defined in header file. erase() is used to ... Read More

multimap::operator= in C++ STL

Sunidhi Bansal
Updated on 22-Apr-2020 11:23:38

162 Views

In this article, we will be discussing the working, syntax, and example of multimap equal ‘=’ operator in C++ STL.What is Multimap in C++ STL?Multimaps are the associative containers, which are similar to map containers. It also facilitates storing the elements formed by a combination of key-value and mapped value in a specific order. In a multimap container, there can be multiple elements associated with the same key. The data is internally always sorted with the help of its associated keys.What is multimap equal to ‘=’ operator?multimap::operator= is equal to operator. This operator is used to copy the elements from ... Read More

multimap::swap() in C++ STL

Sunidhi Bansal
Updated on 22-Apr-2020 11:19:07

267 Views

In this article, we will be discussing the working, syntax, and examples of multimap::swap() function in C++ STL.What is Multimap in C++ STL?Multimaps are the associative containers, which are similar to map containers. It also facilitates storing the elements formed by a combination of key-value and mapped value in a specific order. In a multimap container, there can be multiple elements associated with the same key. The data is internally always sorted with the help of its associated keys.What is multimap::swap()?multimap::swap() function is an inbuilt function in C++ STL, which is defined in header file. swap() is used to ... Read More

strchr() function in C++ and its applications

Sunidhi Bansal
Updated on 22-Apr-2020 11:11:32

2K+ Views

In this article, we will be discussing the working, syntax, and examples of strchr() function in C++ STL.What is strchr()?strchr() function is an inbuilt function in C++ STL, which is defined in the header file. strchr() function is used to find when the character first occurred in the string. This function returns the pointer to the location where the character first appeared in the string.If the character doesn’t exist in the string the function returns the null pointer.Syntaxchar* strchr( char* str, char charac );ParametersThe function accepts the following parameter(s)−str − It is the string in which we have to ... Read More

XOR of all Prime numbers in an Array in C++

sudhir sharma
Updated on 20-Apr-2020 11:57:01

267 Views

In this problem, we are given an array of n elements. Our task is to print xor of all prime numbers of the array.Let’s take an example to understand the problem,Input − {2, 6, 8, 9, 11}Output −To solve this problem, we will find all the prime numbers of the array and the xor them to find the result. To check if the element is prime or not, we will use sieve’s algorithm and then xor all elements that are prime.ExampleProgram to show the implementation of our solution, Live Demo#include

XOR of all subarray XORs in C++

sudhir sharma
Updated on 20-Apr-2020 11:55:42

466 Views

In this problem, we are given an array of n elements. Our task is to print XOR of XORs all possible subarrays (taken in order) created from elements of the array.Let’s take an example to understand the problem, Input − array = {1, 3, 6, 8}Output − 0Explanation −(1) ^ (3) ^ (6) ^ (8) ^ (1^3) ^ (3^6)^ (6^8) ^ (1^3^6) ^ (3^6^8) ^ (1^3^6^8)To solve this problem, a simple solution could be iterating over all the subarray and find xors. But this is an inefficient approach. A better approach could be counting the frequency of each element of ... Read More

XOR of all the elements in the given range [L, R] in C++

sudhir sharma
Updated on 20-Apr-2020 11:54:06

656 Views

In this problem, we are given two integer L and R denoting a range. Our task is to find xor of all elements within the range [L, R].Let’s take an example to understand the problem, Input − L=3, R = 6Explanation − 3^4^5^6 =To solve this problem, we will find the MSB of R. the MSB of the answer will not be greater than R. Now, we will find the parity of count of the number of bits from 0 to MSB.Now, to find the parity count for an ith bit, we can see that the state of an ith ... Read More

Advertisements