Prateek Jangid has Published 190 Articles

Queries for Bitwise OR in the Index Range [L, R] of the Given Array using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 10:01:24

810 Views

In this article, we are given an array of integers. We are tasked to find the bitwise OR of all the numbers present in the given range, for example, Input: arr[] = {1, 3, 1, 2, 3, 4}, q[] = {{0, 1}, {3, 5}} Output: 3 7 1 OR 3 ... Read More

Queries for number of array elements in a range with Kth Bit Set using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 09:56:19

225 Views

In this article we will discuss a problem of finding the number of elements present in the given range that have a kth bit set, for example −Input : arr[] = { 4, 5, 7, 2 } Query 1: L = 2, R = 4, K = 4 Query 2: ... Read More

Queries for greater than and not less than using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 09:37:59

396 Views

In this article, we are given a problem, we are given an array, and there are two types of queries we need to answer.Type 0 − we have to calculate the number of greater elements than or equal to x(given value).Type 1 − we have to calculate the number of ... Read More

Queries for bitwise AND in the index range [L, R] of the given Array using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 08:07:35

1K+ Views

In this article, we have given a problem in which we are given an array of integers, and we are tasked to find the bitwise AND of the given ranges, for example 7minus;Input: arr[ ] = {1, 3, 1, 2, 32, 3, 3, 4, 4}, q[ ] = {{0, 1}, ... Read More

Find the Pentagonal Pyramidal Number using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 07:40:29

115 Views

A pentagonal pyramidal number is equal to the number of items in a pentagonal base pyramid. Look at some Pentagonal numbers below.Sum of Pentagonal Numbers till N equals to Nth Pentagonal Pyramidal Number. In this article, we will discuss finding the Nth Pentagonal Pyramidal number, for exampleInput : N = ... Read More

Find the Pell Number using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 07:29:58

411 Views

In the given problem, we are given an integer n we need to find Pn, i.e., the pell number in that position. Now, as we know, pell number is a part of a series given by this formula −Pn = 2*Pn-1 + Pn-2With first two starting numbers − P0 = ... Read More

C++ Return Previous Element in an Expanding Matrix

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 07:23:15

121 Views

Discuss a problem based on expanding the matrix. Expanding matrix is a matrix whose size continuously increases by some factor.Here we have a matrix of characters whose size is expanding by a factor of 2, i.e., if the original size of the matrix is N * N, then the size ... Read More

Find the Pattern of 1’s inside 0’s using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 07:21:51

235 Views

In this article we are given values of several rows and several columns. We need to print a Box pattern such that 1’s get printed on 1st row, 1st column, last row, last column, and 0’s get printed on remaining elements. For example −Input : rows = 5, columns = ... Read More

C++ Reverse a path in BST using queue

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 07:18:09

114 Views

Given a binary search tree, and we are required to reverse its path from a particular key, for example.Approach to Find the SolutionIn this approach, we will make a queue and push all the nodes until we get the root.Example  #include using namespace std; struct node {    int ... Read More

Find the Pairs of Positive Negative values in an Array using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 07:14:42

279 Views

In this article, we have an array containing distinct elements. We need to print the pairs of positive-negative values in the array with the same absolute value and print them in sorted order for examples −Input : arr[] = { 1, -1, 11, 12, 56, 77, -56, -12, -88} Output ... Read More

Advertisements