Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
Find a Corresponding Node of a Binary Tree in a Clone of That Tree in C++
Suppose we have two binary trees original and cloned and given a reference to a node target in the original tree. The cloned tree is actually a copy of the original tree. We have to find a reference to the same node in the cloned tree.So if the tree is like below and the target is 3, then the output will be 3.To solve this, we will follow these steps −Define a method called solve(), this will take the node1m node2 and targetif node1 is null, then return nullif node1 is target and value of node 1 is the value ...
Read MoreMenu Driven C++ Program for a Simple Calculator
In this tutorial, we will be discussing a program to create a menu driven program for a simple calculator.This program will give user the ability to choose among the following mathematical operations − addition, subtraction, multiplication, division, HCF and LCM.Example#include using namespace std; //displaying the menu void menu(){ cout
Read MoreDice Roll Simulation in C++
Suppose a die simulator generates a random number from 1 to 6 for each roll. We want to introduced a constraint to the generator such that it cannot roll the number i more than rollMax[i] (1-indexed) consecutive times. Consider we have an array of integers rollMax and an integer n, we have to return the number of distinct sequences that can be obtained with exact n rolls. The two sequences are considered different if at least one element differs from each other. So if n is 2, then rollMax = [1, 1, 2, 2, 2, 3], then the output will ...
Read MoreTemplates and Static variables in C++
In this tutorial, we will be discussing a program to understand templates and static variables in C++.In case of function and class templates, each instance of the templates has its own local copy of the variables.Example#include using namespace std; template void fun(const T& x){ static int i = 10; cout
Read Moreis_standard_layout template in C++
In this article we will be discussing the working, syntax and examples of std::is_standard_layout template in C++ STL.is_standard_layout is a template which comes under the header file. This template is used to check whether the given type T is a standard layout or not.What is a standard layout in C++?Standard Layout type is a type in which is of simple linear structure (like we see in array) and access control which can be easily used to communicate with the program written in other programming languages. This is a type which is written with the idea of one code for ...
Read MoreMaximum of all Subarrays of size k using set in C++ STL
In this tutorial, we will be discussing a program to get maximum of all subarrays of size k using set in C++ STL.For this we will be provided with a array of size N and integer K. Our task is to get the maximum element in each K elements, add them up and print it out.Example#include using namespace std; //returning sum of maximum elements int maxOfSubarrays(int arr[], int n, int k){ set q; set::reverse_iterator it; //inserting elements for (int i = 0; i < k; i++) { q.insert(pair(arr[i], i)); } ...
Read MoreBitwise ORs of Subarrays in C++
Suppose we have an array A of non-negative integers. For every (contiguous) subarray say B = [A[i], A[i+1], ..., A[j]] (with i
Read MoreMeeting Scheduler in C++
Suppose we have the availability time slots lists slots1 and slots2 of two people and a meeting duration d, we have to find the earliest time slot that works for both of them and is of duration d. If there is no common time slot that satisfies the requirements, then show an empty array. Here the format of a time slot is an array of two elements [start, end] representing an inclusive time range from start to end. we can assume that no two availability slots of the same person intersect with each other. That is, for any two time ...
Read Morematch_results begin() and end() function in C++ STL
In this article we will be discussing the working, syntax and examples of match_results::begin() and match_results::end() functions in C++ STL.What is a match_results in C++ STL?std::match_results is a specialized container-like class which is used to hold the collection of character sequences which are matched. In this container class a regex match operation finds the matches of the target sequence.What is match_results::begin()?match_results::begin() function is an inbuilt function in C++ STL, which is defined in header file. This function returns an iterator which is pointing to the first element in the match_results object. The match_results::begin() and match_results::end() are together used to ...
Read MoreRLE Iterator in C++
Suppose we have to create an iterator that iterates through a run-length encoded sequence. Here the iterator is initialized by calling RLEIterator(int[] A), where A is a run-length encoding of a sequence. So we can say that for all even i, A[i] tells us the number of times that the non-negative integer value A[i+1] is repeated in the sequence. Here iterator supports one function −next(int n): This function exhausts the next n elements (n >= 1) and returns the last element exhausted in this way. So if there is no element left to exhaust, next returns -1 instead.Suppose we start ...
Read More