
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7197 Articles for C++

1K+ Views
In this article, we will find out the number of subarrays having a sum less than K using C++. In this problem, we have an array arr[] and an integer K. So now we have to find subarrays that have a sum less than K. Here is the example −Input : arr[] = {1, 11, 2, 3, 15} K = 10 Output : 4 {1}, {2}, {3} and {2, 3}Approach to Find SolutionNow we will use two different methods to solve the given problem −Brute ForceIn this approach, we will iterate through all the subarrays and calculate their sum and ... Read More

963 Views
In this article, we will solve the number of subarrays having sum in a given range using the C++ program. We have an array arr[] of positive integers, and a range {L, R} and we have to calculate the total number of subarrays having sum in the given range form L to R. So here is the simple example for the problem −Input : arr[] = {1, 4, 6}, L = 3, R = 8 Output : 3 The subarrays are {1, 4}, {4}, {6}. Input : arr[] = {2, 3, 5, 8}, L = 4, ... Read More

875 Views
In this article, we will provide a brief explanation on solving the number of subarrays that have bitwise OR>=K in C++. So we have an array arr[] and an integer K, and we have to find the number of subarrays that have OR(bitwise or) greater than or equal to K. So here is the example of the given problem −Input: arr[] = {1, 2, 3} K = 3 Output: 4 Bitwise OR of sub-arrays: {1} = 1 {1, 2} = 3 {1, 2, 3} = 3 {2} = 2 {2, 3} = 3 {3} = 3 4 sub-arrays have ... Read More

189 Views
There are n number of intermediate train stations between point X and Y. Count the number of different ways trains can be arranged to stop at s stations such that no two stations are next to each other. So in this article, we will explain every possible approach to find out the number of stopping stations. Looking at the problem, we can find that we need to find combinations by which trains can be stopped at s number of stations.Approaches to Solve the ProblemLet's take an example that there are eight intermediate stations and we need to find the ways ... Read More

235 Views
In this article we are going to find number of solution of equation n = x + n ⊕ x, i.e we need to find number of values of x possible with given value n such that n = x + n ⊕ x where ⊕ represents XOR operation.Now we will discuss the complete information regarding number of solutions of n = x + n ⊕ x with an appropriate examples.Brute Force MethodWe can simple use brute force approach in order to find number of solution, i.e for given value of n we apply every integer value of x starting ... Read More

288 Views
In this article, we will describe the important information on solving the number of sinks nodes in a graph. We have a Directed Acyclic Graph with N nodes (1 to N) and M edges in this problem. The goal is to find how many sink nodes are there in the given graph. A sink node is a node that does not produce any outgoing edges. So here is a simple example −Input : n = 4, m = 2 Edges[] = {{2, 3}, {4, 3}} Output : 2Simple Approach to Find the SolutionIn this approach, we will go through ... Read More

229 Views
In this article, we will provide complete information to determine the number of siblings of a given node in the n-ary tree. We need to find the node's siblings with the value of key as given by the user; if it is non, then output as -1. There is only one approach that we can use −Simple ApproachIn this approach, we will go through all the nodes and check if a child has the same value as the user. If it exists, we answer a number of children - 1(the given value).Example #include using namespace std; class Node { ... Read More

302 Views
In this article, we have to find the number of segments or subarrays in a given sequence where elements greater than the given number X.We can count overlapping segments only once, and two contiguous elements or segments should not count separately. So here is the basic example of the given problem −Input : arr[ ] = { 9, 6, 7, 11, 5, 7, 8, 10, 3}, X = 7 Output : 3 Explanation : { 9 }, { 11 } and { 8, 10 } are the segments greater than 7 Input : arr[ ] = { 9, 6, ... Read More

506 Views
In this article, we will explain the approaches to find the number of reflexive relations on a set. In this problem, we are given with number n, and on a set of n natural numbers, we must determine the number of reflexive relations.Reflexive Relation − A relation in a set A is called reflexive if ( a, a ) belongs to R for every 'a' belongs to set A. For example −Input : x = 1 Output : 1 Explanation : set = { 1 }, reflexive relations on A * A : { { 1 } } Input ... Read More