Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Articles by Sunidhi Bansal
Page 16 of 81
Print n numbers such that their sum is a perfect square
Given n numbers, we need to find n numbers whose sum is a perfect square. The solution uses the first n odd numbers, as the sum of first n odd numbers is always n². Input : 5 Output : 1 3 5 7 9 1+3+5+7+9=25 i.e (5)² Syntax for(i = 1; i
Read MoreCount odd and even digits in a number in PL/SQL
We are given a positive integer of digits and the task is to calculate the count of odd and even digits in a number using PL/SQL. PL/SQL is a combination of SQL along with the procedural features of programming languages. It was developed by Oracle Corporation in the early 90's to enhance the capabilities of SQL. PL/SQL is one of three key programming languages embedded in the Oracle Database, along with SQL itself and Java. Input int number = 23146579 Output count of odd digits in a number are : 5 count of even digits in a number are : ...
Read MoreFind elements of an array which are divisible by N using STL in C++
Given with an array and the task is to find the number which are divisible by N using standard template library in C++.To solve this problem we are using the function count_if() present in C++ standard template library.What is a count_if() function?Syntaxcount_if(LowerBound, UpperBound, function)Description − This function returns the number of elements in an array that satisfies the given condition. It takes three parameters.Lower Bound − It points to the first element of an array or any other sequence.Upper Bound − It points to the last element of an array or any other sequence.Function − It returns the Boolean value ...
Read MoreCount number of ways to reach destination in a Maze in C++
Given a Maze represented as a row X col matrix in which the obstacle is represented as -1 and a clear cell has value other than -1. The goal is to start from the first cell arr[0][0] and reach the last cell arr[row][col] such that only two moves are allowed:Right move arr[i][j] to arr[i][j+1] and Down move arr[i][j] to arr[i+1][j].Let us understand with examples.Input - arr[row][col] = {{0, 0, 0}, {-1, -1, 0}, {0, 0, 0}}Output - Count of number of ways to reach destination in a Maze are: 1Explanation 0 1 2 0 0 ...
Read MoreCount numbers in range such that digits in it and it's product with q are unequal in C++
Given two numbers start and end as range variables and an integer q as input. The goal is to find the numbers within a range such that the number and its product with q have no common digits.If the number is 5 and q is 3 then the product will be 15. Both 5 and 15 have a common digit 5.If the number is 2 and q is 5 then the product will be 10. Both 2 and 10 have no common digit.Let us understand with examples.For ExampleInput - start = 5, end = 10, q = 2Output - Count ...
Read MoreCount Numbers in Range with difference between Sum of digits at even and odd positions as Prime in C++
Given two numbers start and end as range variables. The goal is to find the count of numbers that lie in this range [start, end] and have a difference of sum of digits at even and sum of digits at odd positions as Prime.That is (sum of digits at even position)-(sum of digits at odd position) = a Prime numberLet us understand with examples.For ExampleInput - start = 230, end = 270Output - Count of Numbers in Range with difference between Sum of digits at even and odd positions as Prime are: 6Explanation - The number(s) between 230 to 270 ...
Read MoreCount of a, b & c after n seconds for given reproduction rate in C++
Given three numbers 'a', 'b' and 'c' as input. The goal is to find the count/value of 'a', 'b' and 'c' after n seconds such that the rate of reproductions are:-Every a changes to b after every 2 secondsEvery b changes to c after every 5 secondsEvery c changes to 2 a after every 12 seconds.Let us understand with examples.For ExampleInput - n_seconds = 62 a = 1 b = 1 c = 1Output - Count of a after n seconds for given reproduction rate is: 0Count of b after n seconds for given reproduction rate is: 33Count of c after ...
Read MoreCount of alphabets whose ASCII values can be formed with the digits of N in C++
Given a long variable containing a positive number as input. The goal is to find the count of alphabets whose ASCII value digits are present in the digits of the number.Pick any two digits from the number and arrange them in a manner such that they form an ASCII value of English alphabets. ASCII values of A-Z start from 65 to 90 and ASCII values of a-z start from 97 to 122.Total numbers that are to be picked will be 26+26=52.Let us understand with examples.For ExampleInput - N_digits = 163465Output - Count of alphabets whose ASCII values can be formed with ...
Read MoreCount of cells in a matrix which give a Fibonacci number when the count of adjacent cells is added in C++
Given a matrix [ ][ ] having dimensions as row x col. The goal is to find the count of cells of matrix that meet the given condition:Value of cell matrix [i][j] + no. of adjacent cells to it = a Fibonacci numberNumbers in Fibonacci series:- 0, 1, 1, 2, 3, 5, 8, 13, 21, 43 …..Let us understand with examples.For ExampleInput - matrix[row][col] = {{1, 4, 1}, {2, 0, 1}, {5, 1, 1}Output - Count of cells in a matrix which give a Fibonacci number when the count of adjacent cells is added are: 4Explanation 0 1 ...
Read MoreCount of different ways to express N as the sum of 1, 3 and 4 in C++
Given a positive number N as input. The goal is to find the number of ways in which we can express N as a sum of 1s, 3s and 4s only. For example, if N is 4 then it can be represented as 1+1+1+1, 3+1, 1+3, 4 so the number of ways will be 4.Let us understand with examples.For ExampleInput - N=5Output - Count of different ways to express N as the sum of 1, 3 and 4 are: 6Explanation - 5 can be represented as:1+1+1+1+11+3+13+1+11+1+34+11+4Input - N=6Output - Count of different ways to express N as the sum of ...
Read More