
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
Found 33676 Articles for Programming

195 Views
We are given an array Arr[] of positive integers of size N. The goal is to count the number of elements in that array which can be represented as sum of parity primes, that is they can be shown as a sum of the same prime number. Ex; 4= 2+2, 6=3+3 or 2+2+2The sum of any two odd or even prime numbers will always be even. And except 0 and 2 all even numbers can be represented as sum of same primes.Let’s understand with examples.Input Arr[] = { 2, 5, 10, 15, 20, 25 }Output Number which satisfy condition : 3Explanation Numbers as ... Read More

381 Views
We are given an array Arr[] of positive integers of size N. The goal is to count the number of trailing zeroes present in the product of all elements of the array.We will do this by counting the factors of each number. We will count 2 and 5 as factors of each number as the product of 2 and 5 is 10 which gives 1 trailing 0. In the end whichever count is smaller gives the count of trailing zeroes in the product. If we have 4 2’s and 6 5’s then there will be 4 trailing zeroes in the ... Read More

449 Views
We are given a positive number N. The goal is to count the number of ways in which the number N can be divided into 3 parts. The parts may or may not be equal. N lies in range [1, 5000].We will do this by using three for loops for 3 parts of the number. Check at the innermost loop that the sum of all three is equal to N. If true, then increment the count of ways.Let’s understand with examples.Input − N=5Output − Number of ways to divide N in 3 parts: 2Explanation − 5 can be shown as ... Read More

125 Views
We are given an integer N which represents the number of cuts applied on a 2D-circle. Each circle divides the circle in two halves. Goal is to find the pieces of the circle after N cuts.Number of pieces= 2 * no. of cutsLet’s understand with examples.Input − N=1Output − Pieces of circle: 2Explanation −Input − N=3Output − Pieces of circle: 6Explanation −Approach used in the below program is as followsWe take N for a number of cuts.Take pieces=1*N.Print the result..Example#include using namespace std; int main(){ int N=2; Int pieces=2*N; cout

205 Views
We are given four arrays A[], B[], C[] and D[]. The goal is to find all quadruples of elements of these arrays such that A[i]+B[j]+C[k]+D[l] =x. All four arrays have the same number of elements N.We will do this by traversing each array once and compare if A[i]+B[j]+C[j]+D[l]==x. If true increment count.Let’s understand with examples.Input A[]={ 1, 2, 3}; B[]={ 2, 3, 2}; C[]={ 4, 3, 1}; D[]={ 3, 1, 1 }; X=12Output Count of Quadruples: 4Explanation Quadruples such as ( A[i] B[j] C[k] D[l] ) are: (2 3 4 3) , (3 2 4 3), (3 3 3 3), (3 2 4 ... Read More

8K+ Views
We are given range variables START and END. The goal is to find the count of prime numbers in the range [START, END].We will check if number i in range is prime by checking if any number other than 1 fully divides it and is between 1 and i/2. If it is prime. Increment count.Let’s understand with examples.Input Start=1 End=20Output Primes in Ranges : 8Explanation Primes between 1 and 20 are: 2, 3, 5, 7, 11, 13, 17, 19.Input Start=100 End=200Output Primes in Ranges : 21Explanation Primes between 100 and 200 are: 101 103 107 109 113 127 131 137 139 149 151 157 163 167 ... Read More

184 Views
We are given an array of strings str[] and a pattern string pat. The goal is to find the string elements of str[] that have pattern pat at the end.We will traverse each string of str and compare last characters with pat. If they match incrementLet’s understand with examples.Input str[]={ “kittens”, “hens”, “deers”, “dogs” } pat=”ens”Output Strings that end with given pattern: 2Explanation Strings “kitt-ens” and “h-ens” end with “ens”.Input str[]={ “tickets”, “wickets”, “bats”, “cricket” } pat=”et”Output Strings that end with given pattern: 1Explanation Strings “wick-et” ends with “et”.Approach used in the below program is as followsWe string array str[] and a pattern string pat.N is ... Read More