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
Programming Articles - Page 1165 of 3363
175 Views
The modified mean of the matrix is defined as follows...(sum(row-wise min) + sum(column-wise max)) / (row_size + column_size)Let's see an example.1 2 3 4 5 6 7 8 9mean = (sum(1 + 4 + 7) + sum(7 + 8 + 9)) / (3 + 3)We have to find the mean first and then count the number of elements that are greater than mean.If we take the above example, then we will get 3 as the count. There are 3 elements that are greater than the mean which is 6.AlgorithmInitialise the matrix.Find the row-wise minimum elements sum.Find the column-wise maximum elements ... Read More
403 Views
You are given a number in string. You need to find how many digits need to be removed to make it divisible by 3.We make a number divisible by removing at most 2 digits. So, the maximum number of digits to be removed to make it divisible by 3 is 2.Let's see some examples.Input92Output1We can remove 2 to make it divisible by 3.Input999Output0The given number itself is divisible by 3.AlgorithmInitialise the number in string.Find the sum of the number.If the sum is divisible by 3, then return 0.If the sum is not divisible by 3 and the length of the ... Read More
225 Views
We need to find the number of digits in the nth number made of given four digits 1, 2, 3, and 4.The series with the above four digits is as follows1, 2, 3, 4, 11, 12, 13, 14, 21, 22, 23, 24...We need to find the number of digits of the nth number from the above series. If you carefully observe the pattern, you will find the following points.There are 4 numbers with digits 1.There are 16 numbers with digits 2.The pattern continues as the powers of 4.Let's see an exampleInput7Output2 The 7th number in the series is 13 and ... Read More
201 Views
The power of a number can be computed using the iterative multiplication or function that the language provides. It's a straightforward thing.Here, we have to find the a raised to power b. And the number of digits in the result. Let's see some examples.Inputa = 5 b = 2Output2 Inputa = 7 b = 6Output6 AlgorithmInitialise the number a and b.Find the value of ab.The ceil of log10(n) will give you number of digits in the number n.Find it and return it.ImplementationFollowing is the implementation of the above algorithm in C++#include using namespace std; int getDigitsCount(int a, int b) ... Read More
158 Views
The power of a number can be computed using the iterative multiplication or function that the language provides. It's a straightforward thing.Here, we have to find the 2 raised to power n. And the number of digits in the result. Let's see some examples.Input5Output2Input10Output4 AlgorithmInitialise the number n.Find the value of 2n.The ceil of log10(n) will give you number of digits in the number n.Find it and return it.ImplementationFollowing is the implementation of the above algorithm in C++#include using namespace std; int getDigitsCount(int n) { return ceil(log10(pow(2, n))); } int main() { int n = 8; ... Read More
414 Views
We are given two numbers n and k. We need to find the count of arrays that can be formed using the n numbers whose sum is k.The number of arrays of size N with sum K is $\dbinom{k - 1}{n - 1}$.This a straightforward formula to find the number arrays that can be formed using n elements whose sum k. Let's see an example.Inputn = 1 k = 2Output1 The only array that can be formed is [2]Inputn = 2 k = 4Output3 The arrays that can be formed are [1, 3], [2, 2], [3, 1].AlgorithmInitialise the numbers n ... Read More
266 Views
In this tutorial, we are going to write a program that finds the number of anomalies in the given array.A number is an anomaly in the given array if the absolute difference between the number and all other numbers is greater than the given number k. Let's see an example.Inputarr = [3, 1, 5, 7] k = 1Output4The absolute difference between all numbers with others is greater than k.AlgorithmInitialise the array.Iterate over the array.Take the element and iterate over the array.Find the absolute difference between the two numbers.If no absolute difference is less than or equal to k than increment ... Read More
154 Views
It's a straightforward problem. We can use the modulo (%) operator to check whether the given number is divisible by 29 or not. Let's see some examples.Input29 254Output1 0AlgorithmImplementationFollowing is the implementation of the above algorithm in C++#include using namespace std; bool isDivisibleBy29(long long n) { return n % 29 == 0; } int main() { cout
4K+ Views
The coefficients of each term of the polynomial are given in an array. We need to multiply the two polynomials. Let's see an example.InputA = [1, 2, 3, 4] B = [4, 3, 2, 1]Output4x6 + 11x5 + 20x4 + 30x3 + 20x2 + 11x1 + 4AlgorithmInitialise two polynomials.Create a new array with a length of two polynomials.Iterate over the two polynomials.Take one term from the first polynomial and multiply it with all the terms in the second polynomial.Store the result in the resultant polynomial.ImplementationFollowing is the implementation of the above algorithm in C++#include using namespace std; int *multiplyTwoPolynomials(int ... Read More
1K+ Views
Given two linked lists with digits in it. We need to multiply two numbers formed by the linked list. It can be done easily by forming the numbers from the two linked lists. Let's see an example.Input1 -> 2 -> NULL 2 -> 3 -> NULLOutput2 -> 7 -> 6 -> NULLAlgorithmInitialise the two linked lists.Initialise two variables with 0 to store the two numbers.Iterate over the two linked lists.Add each digit to the respective number variable at the end.Multiply the resultant numbers and store the result in a variable.Create a new list with the result.Print the new list.ImplementationFollowing is ... Read More