Arnab Chakraborty has Published 4293 Articles

How to find the minimum and maximum element of an Array using STL in C++?

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 13:09:59

2K+ Views

Here we will see how to find the maximum and minimum element from an array. So if the array is like [12, 45, 74, 32, 66, 96, 21, 32, 27], then max element is 96, and min element is 12. We can use the max_element() function and min_element() function, present ... Read More

How to delete last element from a set in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 13:05:10

1K+ Views

Suppose we have one STL set in C++. There are few elements. We have to delete the last element from that set. So if the elements are like [10, 41, 54, 20, 23, 69, 84, 75], then the set will be like [10 20 23 41 54 69 75 84], ... Read More

How to delete last element from a map in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 12:55:24

622 Views

Here we will see how to delete the last element from C++ STL map. The map is the hash table based data type, it has key and value. We can use the prev() method to get last element, and erase() function to delete as follows.Example Live Demo#include #include using namespace std; ... Read More

How to delete last element from a List in C++ STL

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 12:52:36

588 Views

Suppose we have one STL list in C++. There are few elements. We have to delete the last element from that list. So if the elements are like [10, 41, 54, 20, 23, 69, 84, 75], then last element is 75. We will see the C++ code to delete last ... Read More

Check if a key is present in a C++ map or unordered_map

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 12:46:43

469 Views

In C++ the Maps and unordered maps are hash tables. They use some keys and their respective key values. Here we will see how to check whether a given key is present in the hash table or not. The code will be like below −Example Live Demo#include #include using namespace std; ... Read More

What is Array Decay in C++? How can it be prevented?

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 12:43:45

189 Views

Here we will see what is Array Decay. The loss of type and dimensions of an array is called array decay. It occurs when we pass the array into a function by pointer or value. The first address is sent to the array which is a pointer. That is why, ... Read More

Find the number of players who roll the dice when the dice output sequence is given in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 12:33:12

130 Views

Suppose we have a string S and a number X. There are M different players who roll the dice. one player keeps on rolling the dice until he gets a number other than X. Here in the string S, S[i] represents the number at ith roll of a dice. We ... Read More

Find the Number of Maximum Product Quadruples in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 12:28:18

226 Views

Suppose we have one integer array with n elements. We have to find the maximum product of a quadruple in the array. So if the array is like [3, 5, 20, 6, 10], then final product is 6000, and elements in quadruple is 10, 5, 6, 20To solve this, we ... Read More

Find the node whose absolute difference with X gives maximum value in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 12:13:47

99 Views

Suppose we have a tree, and the weights of all the nodes and an integer x. We have to find the node i, such that |weight[i] - x| is minimum. If the graph is like below, and x = 15Output will be 3. Now for different nodes, it will be ... Read More

Find the minimum value to be added so that array becomes balanced in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 17-Dec-2019 12:08:13

212 Views

Suppose we have an array A with n elements. And the n is even. We have to find the value that needs to balance the array. As the size of the array is even, then we can make two halves. Sum of the left half and sum of the right ... Read More

Advertisements