Prateek Jangid has Published 165 Articles

Rank of All Elements in an Array using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 10:20:02

1K+ Views

In the given problem, we need to rank all the given elements of an array, with the smallest number having the smallest rank and the largest having the largest rank. We also need to change the ranks of a number depending on their frequencies, for examples −Input : 20 30 ... Read More

Range Sum Queries Without Updates using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 10:09:29

472 Views

In this article, we will give an array of size n, which will be an integer. Then, we will compute the sum of elements from index L to index R and execute the queries multiple times, or we need to calculate the sum of the given range from [L, R]. ... Read More

Queries to Print All the Divisors of n using C++

Prateek Jangid

Prateek Jangid

Updated on 26-Nov-2021 10:05:03

578 Views

In the given problem, we are required to print all the divisors of a given integer n.Input: 15 Output: 1 3 5 15 Explanation Divisors of 15 are: 1, 3, 5, 15 Input: 30 Output: 1 2 3 5 15 30In the given problem, we can apply the approach ... 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

375 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

544 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

279 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

660 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

227 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

399 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

Previous 1 ... 6 7 8 9 10 ... 17 Next
Advertisements