
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

481 Views
We are given an interval [first, last]. The goal is to find the count of numbers that have the same first and last digit within this interval. For example, 232 has the same first and last digit as 2.We will do this by traversing from i=first to i=last. For each number I compare its first digit with the last digit, if they are the same increment the count.Let’s understand with examples.Input − first=8 last=40Output − Count of numbers with same first and last digits − 5Explanation − Numbers between 8 and 40 with same first and last digit −8, 9, ... Read More

2K+ Views
The goal here is to count the number of objects of a class that are being created using a static member function. A static data member is shared by all objects of the class commonly. If no value is given, a static data member is always initialized with 0. A static member function can only use static data members of that class. We are using a class Student here. We will declare a static data member count which will store the count of objects. A static member function rollCall(void) will display the count of objects as roll no.s of students ... Read More

309 Views
We are given with a positive integer K and an array Ops[] which contains integers. The goal is to find the number of operations required to reduce K such that it becomes less than 0. Operations are −First operation is K + Ops[0], first element added to KAfter 1. Add Ops[i] to K until K

180 Views
We are given a matrix of size NXN. The goal is to find the count of all valid pairs of indexes (i, j) such that the sum elements of column j is greater than the sum of elements of row i.We will do this by traversing the matrix and calculate sums of elements of each row and column.Store sum of elements of each in rowsum[N] and sum of elements of each column in colsum[N].Now make pairs of rowsum[i] and colsum[j] and check if colsum[j]>rowsum[i]. If true increment count for such pairs.Let’s understand with examples.Input-: matrix= { { 1, 2, ... Read More

1K+ Views
We are given with an array arr[] of N elements. The goal is to find the count of all valid pairs of indexes (i, j) such that either arr[i] is divisible by arr[j] or arr[j] is divisible by arr[i] and i!=j.We will do this by traversing the array arr[] using two for loops for each number of pair and check if arr[i]%arr[j]==0 or arr[j]%arr[i]==0 when i!=j. If true increment count of pairs.Let’s understand with examples.Input − Arr[]= { 2, 4, 3, 6 } N=4Output − Count of valid pairs − 3Explanation − Valid pairs are −Arr[0] & Arr[1] → (2, ... Read More

835 Views
We are given an array which contains the length of sides of triangles. The goal is to find the number of possible triangles that can be made by taking any three sides from that array.We will do this by checking if the sum of any two is always > third side. If yes these three sides can make a triangle. Increment count of possible triangles that can be made.Let’s understand with examples.Input − arr[]= {1, 2, 4, 5}Output − Count of possible triangles − 1Explanation − Sides (2, 4, 5) can only make a triangle as 2+4>5 & 4+5>2 & ... Read More

1K+ Views
In this article, We are given an array arr[] of integers with length n. Our task is to count the number of triplets such that the sum of any two numbers is equal to the third number. Example Here is an example of counting the triplets whose sum of any two numbers equals the third one: Input: arr[]= {1, 2, 2, 3, 4} Output: 4 The explanation of the above example is as follows: Triplet 1: (1, 2, 3) => 1+2=3 Triplet 2: (1, 2, 3) => 1+2=3 Triplet ... Read More

250 Views
We are given with an array of distinct elements that are unsorted. The goal is to find the cross lines after the array is sorted. Cross lines are counted as shown below −Arr[]={ 1, 2, 4, 3, 5 } There are 3 cross lines as shown belowArr[]= { 1, 2, 3, 4, 5 }. There are no cross lines as the array is already sorted.We will count the cross lines using insertion sort in which an element from right is added to sorted elements on its left. Each time the element is added in the sorted part, increment count as ... Read More

383 Views
We are given four integers L, R, A and B. The goal is to find the count of numbers in range [L, R] that fully divide either A or B or both.We will do this by traversing from L to R and for each number if number%A==0 or number%B==0 then increment count of divisors.Let’s understand with examples.Input − L=10, R=15, A=4, B=3Output − Count of divisors of A or B − 2Explanation −Number 12 is fully divisible by 3 and 4. Number 15 is fully divisible by 3 only. Total divisors=2Input − L=20, R=30, A=17, B=19Output − Count of divisors ... Read More