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
C++ Articles - Page 177 of 719
112 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. An element can lend power to its adjacent element or any other elements within the distance less than base.Let us see various input output scenarios for this -In − int arr[] = {1, 1, 0, 1, 1, 0, 1}, int base = 7Out −Minimum 1s to lend power to make ... Read More
410 Views
Suppose we are given three integer numbers n, x, y, and z. We have to make a sequence from the given integers where the first item of the sequence is (x modulo 231). Other than the first element, other elements in the sequence ai = (a(i-1) * y + z) modulo 231 , where 1 ≤ i ≤ n - 1. We have to find out the number of distinct integers in the sequence we made.So, if the input is like n = 5, x = 1, y = 2, z = 1, then the output will be 5.The unique ... Read More
438 Views
Suppose there is a film festival going on that showcase various movies from various countries. Now, an attendee wants to attend the maximum number of movies that do not overlap with each other and we have to help them to find out how many movies they can attend.There is a structure Movie that has the following members −The beginning time of the movie.The duration of the movie.The ending time of the movie.There is another structure Festival with the following members −The number of movies at the festival.An array of type Movie whose size is similar to the number of movies ... Read More
390 Views
Suppose we are given a list containing several integer numbers. We have to find out the difference between each pair of values in the array and find out the k-th smallest difference number. The index starts at 0 and the value k is given to us as input.So, if the input is like numbers = {2, 6, 4, 8}, k = 2, then the output will be 2.The differences between the pairs are −(2, 6) = 4(2, 4) = 2(2, 8) = 6(6, 4) = 2(6, 8) = 2(4, 8) = 4If we sort the values, it becomes 2, 2, ... Read More
344 Views
Suppose we are given a positive integer number. We have to spell the number in words; like if a number "56" is given as input the output will be "Fifty-Six". The range of conversion is up to a billion.So, if the input is like input = 5678, then the output will be Five Thousand Six Hundred Seventy-Eight.To solve this, we will follow these steps −Define an array ‘numbers’ that contain pairs such as − {{"Billion", 1000000000}, {"Million", 1000000}, {"Thousand", 1000}, {"Hundred", 100}, {"Ninety", 90}, {"Eighty", 80}, {"Seventy", 70}, {"Sixty", 60}, {"Fifty", 50}, {"Forty", 40}, {"Thirty", 30}, {"Twenty", 20}, {"Nineteen", 19}, ... Read More
1K+ Views
Suppose we are given an encoded message that is a string of integer numbers. Now, these integer numbers can be mapped to a specific letter in the alphabet. a is mapped to 1, b is mapped to 2, c is mapped to 3, and so on. There is also a character '*' that can be in the message and that can be mapped to any of the numbers from 1 to 9. So given a message 'input', we have to find out how many ways it can be decoded.So, if the input is like input = "18", then the output ... Read More
146 Views
Suppose we are given an array arr that contains n positive integer numbers. We are also given an integer number j. The task we have to perform is to merge j numbers into a single number by adding them. The cost of merging is equal to the addition of the j numbers we have selected. We have to find out the minimum possible cost for this merging operation.So, if the input is like arr = [2, 5, 6, 2, 3, 1, 3], j = 4, then the output will be 31.Cost to merge 2, 3, 1, 3 is equal to ... Read More
287 Views
Suppose we are given a matrix that contains integer values. We have to find out the submatrices from the matrix where the sum of elements of the matrices is equal to a given target sum value. We return the number of submatrices.So, if the input is like0010010001011101and target = 5, then the output will be 3.The number of submatrices whose sum of elements is equal to 6 is 2.To solve this, we will follow these steps −n := size of matm := (if n is same as 0, then 0, otherwise size of mat[0])if m > n, then −Define one ... Read More
476 Views
Suppose we are given a matrix that contains only two values; 1s and 0s. We have to find out the number of submatrices in the given matrix that contains all 1s. We print the value as output.So, if the input is like0010010001011101then the output will be 12.To solve this, we will follow these steps −n := size of matrixm := size of matrix[0]Define an array add of size: n+1 x m+1.for initialize i := 0, when i < n, update (increase i by 1), do −for initialize j := 0, when j < m, update (increase j by 1), do ... Read More
271 Views
Suppose we have a list of 2D Cartesian coordinate points (x, y). We can connect (x0, y0) and (x1, y1), whose cost is |x0 - x1| + |y0 - y1|. If we are allowed to connect any number of points, we have to find the minimum cost necessary such that every point is connected by a path.So, if the input is like points = [[0, 0], [0, 2], [0, -2], [2, 0], [-2, 0], [2, 3], [2, -3]], then the output will be 14 because, from (0, 0) to (0, 2), (0, -2), (2, 0), (-2, 0), costs are 2, ... Read More