Sunidhi Bansal has Published 1101 Articles

Maximize the sum of array by multiplying prefix of array with -1 in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 22-Oct-2021 07:30:50

202 Views

We are given an integer array and the task is to firstly fetch the prefix of an array and then multiply it with -1, secondly calculate the prefix sum of an array and lastly find the maximum sum from the prefix array generated.Prefix array is generated as −First element of ... Read More

Minimum sum submatrix in a given 2D array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 22-Oct-2021 06:40:12

399 Views

We are given a 2-D array of integer elements forming the matrix. The task is to calculate the count of minimum sum by pulling the submatrix from the matrix so formed.Let us see various input output scenarios for this -In −int matrix[size][size] = { {2, 3, -1, 5}, {-2, 9, ... Read More

Minimum no. of iterations to pass information to all nodes in the tree in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 21-Oct-2021 13:41:59

532 Views

We are given a tree data structure with ‘n’ number of nodes. The given tree will have a root node and respective children which can be any number and further child can have any number of children. The task is to find the minimum number of iterations required by a ... Read More

Minimum 1s to lend power to make whole array powerful using C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 21-Oct-2021 12:20:54

42 Views

We are given a binary array which can store digits 1’s and 0’s of any given size and an integer variable let’s say, base. The task is to calculate the minimum 1’s that can lend power to other elements of a binary array such that the entire array becomes powerful. ... Read More

C++ Program for dot product and cross product of two vectors

Sunidhi Bansal

Sunidhi Bansal

Updated on 12-Aug-2021 14:28:43

6K+ Views

We are given two vectors let’s say vector A and vector B containing x, y, and directions, and the task is to find the cross product and dot product of the two given vector arrays.What is a vector?In mathematics, a quantity that has a magnitude and a direction is known ... Read More

Count of AP (Arithmetic Progression) Subsequences in an array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Jan-2021 08:42:04

420 Views

Given an array arr[] containing integer elements. The goal is to count the number of Arithmetic Progression subsequences inside arr[]. The range of elements inside arr[] are [1, 1000000].Empty sequence or single element will also be counted.Let us understand with examples.For ExampleInput - arr[] = {1, 2, 3}Output - Count of ... Read More

Count of number of given string in 2D character array in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Jan-2021 08:41:06

456 Views

The following problem is an example of daily newspaper crossword, here we are given a 2-Dimensional character array and the problem statement is to find out the given word from the 2-Dimensional character array maze.The search algorithm includes finding the individual characters from Top-to-Bottom, Right-to-Left and vice-versa but not diagonally.Let ... Read More

Count number of paths whose weight is exactly X and has at-least one edge of weight M in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Jan-2021 08:35:48

99 Views

We are given a tree which can have endless levels, a variable child which will store the number of children a node can have, a variable weight which will store the weight associated with the path and a variable path that will store the path and task is to calculate ... Read More

Count of arrays having consecutive element with different values in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Jan-2021 08:35:13

316 Views

Given three variables size, max_val, last_element as input. The goal is to find the count of different arrays that can be formed in a manner such that they have size elements, have elements between 1 and max_val and the first element is always 1 and the last element is always ... Read More

Count of divisors having more set bits than quotient on dividing N in C++

Sunidhi Bansal

Sunidhi Bansal

Updated on 29-Jan-2021 08:34:33

67 Views

We are given with an integer number let's say, N which is considered as a divisor and it will be divided with the numbers starting from the 1 - N and the task is to calculate the count of those divisors which have more number of set bits than the ... Read More

Advertisements