- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- 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 7347 Articles for C++
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
2K+ Views
We are given two numbers num_1 and num_2. The goal is to count the number of carry operations required if the numbers are added. If numbers are 123 and 157 then carry operations will be 1. (7+3=10, 1+2+5=8, 1+1=2 ).Let us understand with examplesInput − num_1=432 num_2=638Output − Count of number of carry operations required to add two numbers are − 2Explanation − From right to left adding digits and counting carry −(2+9=10, carry 1 ) count=1, (1+3+3=7, carry 0 ) count=1, (4+6=10, carry 1 ) count=2Input − num_1=9999 num_2=111Output − Count of number of carry operations required to add ... Read More
![Arnab Chakraborty](https://www.tutorialspoint.com/assets/profiles/123881/profile/60_2940367-1661162113.png)
57 Views
Suppose we have a list of numbers called nums and another value k. We have to find the minimum number of numbers that we need to insert into nums such that we can make any number from [1, k] using some subset in nums.So, if the input is like nums = [3, 5], k = 6, then the output will be 2, as we have to insert 1, 2, so we can make : 1 = [1], 2 = [2], 3 = [3], 4 = [1, 3], 5 = [5], 6 = [1, 5].To solve this, we will follow these ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
71 Views
We are given a number d which represents the number of digits. The goal is to find the count of positive integers with 0 as a digit and have maximum d digits. Count all 1 digit, 2 digit, 3 digit….d digit positive numbers containing at least one 0.We will first find numbers the count of numbers that have d digits with at least one 0. Let’s say d=3. To make a 3-digit number with at least one 0, possible ways are −Here d1 can have 1 to 9 : 9 ways d2 can have 0-9 : 10 ways d3 can ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
129 Views
We are given a rectangle with dimensions as height X width. The rectangle is represented on a 2D coordinate system with the left-lower corner at point (0, 0). So the goal is to count the number of rhombi possible inside this rectangle such that all these conditions are met −The rhombus has an area more than 0.The diagonals of the rhombus are parallel to the x and y axis.The rhombus has integer coordinates for all corners.Let us understand with examplesInput − length=3 width=3Output − Count of number of rhombi possible inside a rectangle of given size are: 4Explanation − Below ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
203 Views
We are given a string representing a digit sequence. Each digit is decoded from 1 to 26 as English Alphabet. 1 is ‘A’, 2 is ‘B’ and so on till 26 as ‘Z’. The goal is to find the count of all possible decodings out of a given digit sequence. If the sequence is ‘123’ then possible decodings are ‘ABC’ ( 1-2-3 ), ‘LC’ (12-3), ‘AW’ (1-23). Count is 3.Let us understand with examples.Input − str[]=”1532”Output − Count of Possible Decodings of a given Digit Sequence are − 2Explanation − Possible decodings are AECB - (1-5-3-2) and OCB (15-3-2).Input − ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
163 Views
We are given a large number. The goal is to count the rotations of num that are divisible by 8.As the rotations can not be done again and again. We will use the divisible by 8 property. If the last three digits are divisible by 8then the number is divisible by 8. If the number is 1800 then it’s rotations will be 1800, 0180, 0018, 8001 out of 1800 is divisible by 8.Let us understand with examples.Input − num=15320Output − Count of rotations divisible by 4 are: 1Explanation − Rotations are −15320, 01532, 20153, 32015, 53201 Out of these, only ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
603 Views
We are given a large number. The goal is to count the rotations of num that are divisible by 4.As the rotations can not be done again and again. We will use the divisible by 4 property. If the last two digits are divisible by 4 then the number is divisible by 4. If the number is 1234 then it’s rotations will be 1234, 4123, 3412, 2341 out of which 3412 will be divisible by 4 as the last two digits 12 is divisible by 4.Let us understand with examples.Input − num=15324Output − Count of rotations divisible by 4 are: ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
113 Views
We are given a linked list. The list is sorted first and then rotated by K number of nodes. The goal is to find the value of K. If we are given below linked list as input which is rotated by K number of nodes −Then original must have been −And we can see K here is 2. Input linked list is a rotation of 2 nodes in the original sorted linked list.Let us understand with examples.Input − List : 5 → 7 → 9 → 1 → 3Output Elements in the linked list are: 5 7 9 1 3Count of ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
115 Views
We are given a number N. The goal is to count the rotations of N that make an odd number and rotations that make an even number. If the number N is 123 its rotations would be 123, 321, 132. The odd rotations are 123 and 321 ( 2 ) and even rotation is 132 ( 1 ).Let us understand with examples.Input − N= 54762Output −Count of rotations of N which are Odd are − 2Count of rotations of N which are Even are − 3Explanation − Rotations are −54762, 25476, 62547, 76254, 47625.Even rotations are 3 − 54762, 25476, ... Read More
![Sunidhi Bansal](https://www.tutorialspoint.com/assets/profiles/124656/profile/60_131452-1581053210.jpg)
694 Views
We are given a matrix consisting of integers. The goal is to find the number of rows in the matrix that have all identical elements in it.If there is 5X4 matrix as shown −15131111115323577777The answer would be 2, row 1 (having all 1’s) and row 3 (having all 7’s) contain the same element.Let us understand with examples.Input matrix = [ 1 1 1 1 ] [ 2 3 2 7 ] [ 3 3 3 3 ]Output − Count of rows in a matrix that consist of same element are − 2Explanation − Row 0 contains all 1’s ... Read More