Digit Separator in C++14
In this article, we will discuss the use of a digit separator in C++. Sometimes, it becomes difficult to read numbers that contain many digits. For example, 1000 is readable but what if more zeros are added to it, let’s say 1000000, now it becomes a little difficult to read, and what will happen if more zeros are added to it.  In real life, commas (, ) are added to the number. For Example: 10, 00, 000. Now it is easy to read, that is ten lakhs....
read more
Maximum profit by buying and selling a share at most K times | Greedy Approach
In share trading, a buyer buys shares and sells on a future date. Given the stock price of N days, the trader is allowed to make at most K transactions, where a new transaction can only start after the previous transaction is complete. The task is to find out the maximum profit that a share trader could have made....
read more
Correct BST whose two nodes are swapped (using Morris Traversal)
Given a Binary Search Tree with two of the nodes of the Binary Search Tree (BST) swapped. The task is to fix (or correct) the BST.Note: The BST will not have duplicates....
read more
unordered_map bucket() in C++ STL
The unordered_map::bucket() is a built-in STL function in C++ which returns the bucket number where the element with the key k is located in the map. Syntax:...
read more
priority_queue::swap() in C++ STL
Priority queues are a type of container adaptors, specifically designed such that the first element of the queue is either the greatest or the smallest of all elements in the queue. However, in C++ STL (by default) the largest element is at the top. We can also create a priority queue having the smallest element at the top by simply passing an extra parameter while creating the priority queue....
read more
list::front() and list::back() in C++ STL
Lists are containers used in C++ to store data in a non-contiguous fashion, Normally, Arrays and Vectors are contiguous in nature, therefore the insertion and deletion operations are costlier as compared to the insertion and deletion option in Lists....
read more
Sum of array using pointer arithmetic
Given an array, write a program to find the sum of array using pointers arithmetic. In this program we make use of * operator . The * (asterisk) operator denotes the value of variable. The * operator at the time of declaration denotes that this is a pointer, otherwise it denotes the value of the memory location pointed by the pointer . sum() function is used to find the sum of the array through pointers....
read more
std::multiplies in C++
Function object for performing multiplication. Effectively calls operator* on two instances of type T....
read more
Modifiers for Vector in C++ STL
Click here for Set 1 of Vectors....
read more
Print individual digits as words without using if or switch
Given a number, print words for individual digits. It is not allowed to use if or switch.Examples:...
read more
C++ Program For Finding Subarray With Given Sum – Set 1 (Nonnegative Numbers)
Given an unsorted array of non-negative integers, find a continuous subarray that adds to a given number. Examples :...
read more
Compute the maximum power with a given condition
Given 3 integers N, M, and K. The task is to find maximum P such that N * KP ? M....
read more