Arnab Chakraborty has Published 4293 Articles

How to sort an array of dates in C/C++?

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Jan-2020 10:52:24

940 Views

Suppose we have an array of dates. Here we will see how to sort then using C or C++ code. The dates are stored in a class (struct can be used in C also). We will use the sort function of the C++ STL. For comparing dates, we have to ... Read More

How to Read and Print an Integer value in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Jan-2020 10:50:31

560 Views

Here we will see how to read integer from user and display in C++. To take input we will use the cin operator, and to display we will use cout operator. The syntax will be like −Input −int x; cin >> x;Output −int x = 110; cout x;    cout

Find numbers of balancing positions in string in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Jan-2020 10:46:27

148 Views

Suppose we have a string. We have to find the balancing position count in that string from where left and right part of the string contains same characters. The frequency of characters does not matter. So if the string is “ABAABA”, then the number of balancing positions is 3. These ... Read More

Find number of pairs (x, y) in an array such that x^y > y^x in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Jan-2020 10:43:48

289 Views

Suppose we have two arrays X and Y of positive integers. Find the number of pairs such that x^y > y^x, where x is an element of X and y is an element of Y. Suppose the X = [2, 1, 6], and Y = [1, 5], then output will ... Read More

Find maximum sum possible equal sum of three stacks in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Jan-2020 10:41:17

237 Views

Suppose we have three stacks of positive numbers. We have to find the possible equal maximum sum of stacks with removal of top elements allowed. The stacks are represented as an array. The first index of the array represents the top element of the stack. Suppose the stack elements are ... Read More

Find maximum height pyramid from the given array of objects in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Jan-2020 10:37:33

760 Views

Suppose we have an array of n objects. Each object has width W[i]. We have to arrange them in a pyramidal way like −Total width of ith is less than (i + 1)thTotal number of objects in the ith is less than (i + 1)thFor example, if the weights are ... Read More

Find Maximum dot product of two arrays with insertion of 0's in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Jan-2020 10:34:38

376 Views

Suppose we have two arrays of positive integers of size m and n. The m > n. We have to maximize the dot product by inserting zeros in the second array. One thing we have to keep in mind that we will not change the ordering of the elements in ... Read More

Find intersection point of lines inside a section in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Jan-2020 10:22:06

198 Views

Suppose we have set of lines in the form y = mx + c. There are sections made by this line and the vertical section. We have to find the intersection point present in the given section or not. Suppose the lines are like −L1 = y = x + ... Read More

Find if there is a rectangle in binary matrix with corners as 1 in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Jan-2020 10:16:32

268 Views

Suppose we have a binary matrix. We have to find if there is any rectangle or sequence in the given matrix whose all four corners are equal to 1. The matrix is like10010001010001010101The result will be yes. Here one rectangle is present, whose corners are with 1s.101010101To solve this we ... Read More

Find four factors of N with maximum product and sum equal to N in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 03-Jan-2020 10:05:31

152 Views

Suppose we have an integer N. The task is to find all factors of N and display the product of four factors of N, such that −Sum of their four factors are equal to NThe product of four factors is maximumSuppose the number is 24, then the product is 1296. ... Read More

Advertisements