
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 7197 Articles for C++

163 Views
We are an equilateral triangle with side length. The goal is to count the number of distinct rectangles that can be present inside the triangle such that horizontal sides of the rectangle are parallel to the base. Also all end points of the rectangle touch the dots as shown.Let us understand with examplesInput − sides=3Output − Count of distinct rectangles inscribed in an equilateral triangle are − 1Explanation − The figure above shows the rectangle.Input − sides=10Output − Count of distinct rectangles inscribed in an equilateral triangle are − 200Approach used in the below program is as followsAs from the ... Read More

964 Views
We are given a num number as input. The goal is to count the number of possible strings of length num such that all adjacent characters have difference between ascii values as 1.If num is 2 then strings will be “ab”, “ba”, “bc”, “cb”, ……..”yz”, “zy”.Let us understand with examplesInput − num=3Output − Count of strings where adjacent characters are of difference one are − 98Explanation − Some sample strings are: “abc”, “aba”, “cde” …..”xyx”, “zyz”, “xyz”.Input − num=2Output − Count of strings where adjacent characters are of difference one are − 50Explanation − Some sample strings are: “ab”, “ba”, ... Read More

135 Views
We are given a number num as input. The goal is to find the number of pairs of form (i, j) such that ((num%i)%j)%num is maximized and i and j both are in range [1, num].Let us understand with examplesInput − num=4Output − Count of pairs of (i, j) such that ((n % i) % j) % n is maximized are − 3Explanation − Pairs will be: (3, 2), (3, 3), (3, 4)Input − num=6Output − Count of pairs of (i, j) such that ((n % i) % j) % n is maximized are − 4Explanation − Pairs will be: ... Read More

195 Views
We are given a string str containing 0s, 1s and other alphabets . It also contains patterns of the form “1(0+)1” where 0+ means any number (>0) of consecutive 0s. The goal is to find such patterns ( “1(0+)1” ) inside string str.Let us understand with examplesInput − str = “abb010bb10111011”Output − Count of occurrences of a “1(0+)1” pattern in a string are − 2Explanation − The patterns inside str are highlighted: “abb010bb10111011”, “abb010bb10111011”Input − str = “01001011001001100”Output − Count of occurrences of a “1(0+)1” pattern in a string are − 4Explanation − The patterns inside str are highlighted: “01001011001001100”, ... Read More

172 Views
We are given a circle with K equidistant points on its circumference. Also we are given two points A and B. The goal is to count the number of triangles possible using these points such that they have an obtuse angle ACB( angle greater than 90o) inside them. The points A and B are such that A < B.Here K=8, A=2, B=5, count of points=2 (C, C’) such that angle LACB, LAC’B are obtuse.Let us understand with examplesInput − k=10, A=2, B=4Output − Count of obtuse angles in a circle with ‘k' equidistant points between 2 given points are − ... Read More

134 Views
We are given a number N and another number L. The goal is to find the numbers between 1 and N that have a difference between the number itself and the sum of its digits is not less than L.If N=23, L=10 then the count of such numbers will be 4.23-(2+3)=18, 22-(2+2)=18, 21-(2+1)=18, 20-(2+0)=18.All above numbers meet the conditionBut 19-(1+9)=9 which is less than L, similarly 18, 17….1.Let us understand with examplesInput − N=30 L=19Output − Count of Numbers such that difference between the number and sum of its digits not less than L are − 1Explanation − Only 30 ... Read More

252 Views
We are given multiple sentences in the form of strings. The goal is to count the number of words that exist in all of the sentences.Note − words containing all lowercase letters will be considered onlyIf sentences are −“ I am learning C language ”“ learning new things is easy ““ Kids are learning healthy habits “Only “learning” exists in all three. So count is 1.Let us understand with examplesInput − “The clothes were dry”, “All the kids were playing”, “Those were the best days”Output − Count of words that are present in all the given sentences are − 2Explanation ... Read More

145 Views
We are given an array arr[] containing integer elements. The goal is to find the count of pairs that can be formed by elements of sub-arrays of arr[] such that each subarray has only distinct elements. If the array is [ 1, 2, 2, 3, 3 ] then subarrays with distinct elements only will be [ 1, 2 ] and [ 2, 3 ]. And pairs will be (1, 2) and (2, 3) hence count of pairs is 2.Let us understand with examplesInput − arr[] = {1, 2, 5, 3 }Output − Count of pairs formed by distinct element sub-arrays ... Read More

201 Views
We are given two variables n and m representing the number of points on a 2D plane. Out of n points, m points are collinear. The goal is to find the number of triangles that can be formed using these n points.Collinear points − The points that lie on the same line are called collinear. Points A and B are collinear.Given n=4 (A, B, C, D ) , m=2 (A, B)Number of triangles −Choosing any three points out of 4 = 4C3But collinear points cannot form triangle so remove possible triangles that will be counted above = 2C3Total triangles= 4C3 ... Read More

760 Views
We are given a string str[] as input. The goal is to count the number of anagram substrings present in str[]. Two strings are anagrams of each other if they contain the same number of characters and all characters occur in both. The order of characters can be different.“abc” is an anagram of “cba”, “bca” etc.Let us understand with examples.Input − str[] = “abccb”Output − Count of total anagram substrings are − 4Explanation − Anagrams are − (b, b), (c, c), (bc, cb), (bcc, ccb)Input − str = “aaa”Output − Count of total anagram substrings are − 4Explanation − Anagrams ... Read More