C++ Articles

Page 201 of 597

Postfix to Infix in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 6K+ Views

In this problem, we are given expression in postfix form and our task is to print the infix form of the expression.Infix expression is an expression in which the operator is in the middle of operands, like operand operator operand.Postfix expression is an expression in which the operator is after operands, like operand operator.Postfix expressions are easily computed by the system but are not human readable. So this conversion is required. Generally reading and editing by the end-user is done on infix notations as they are parenthesis separated hence easily understandable for humans.Let’s take an example to understand the problemInput ...

Read More

Possible two sets from first N natural numbers difference of sums as D in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 137 Views

In this problem, we are given two integer N and D. Our task is to check whether it is possible to have to sets from the set of first N natural numbers that have a difference of D.Let’s take an example to understand the problem, Input − N=5 D =3Output − YesExplanation −Out of 1, 2, 3, 4, 5. We can have two sets set1= {1, 2, 3} and set2 = {4, 5}, this will give difference 3. {4+5} - {1+2+3} = 9- 6 = 3For solving this problem, we will have some mathematical calculations.We know, the sum of all number ...

Read More

Possible to make a divisible by 3 number using all digits in an array in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 719 Views

In this problem, we are given an array. Our task is to check whether a number generated by using all digits of the elements of the array is divisible by 3. If possible then print “Yes” otherwise print “No”.Let’s take an example to understand the problemInput − arr = {3, 5, 91, }Output − YESExplanation − The number 5193 is divisible by 3. So, our answer is YES.To solve this problem, we will check its divisibility by 3.Divisibility by 3 − a number is divisible by 3 if the sum of its digits is divisible by 3.Now, we will have ...

Read More

Possible to form a triangle from array values in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 5K+ Views

In this problem, we are given an array of integers. Our task is to check if the creation of a non-degenerate triangle taking the elements of the array as sides of the triangle.Non-degenerate triangle − it is a triangle that has a positive area. The condition for a non-degenerate triangle with sides a, b, c is −a + b > c a + c > b b + c > aLet’s take an example to understand the problem better −Input − arr[2, 5 ,9, 4, 3]Output − YesExplanation − the triangle formed is 2 3 4.To solve this problem, we ...

Read More

Possible timings in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 114 Views

In this problem, we are given two-digit timing using a glow digit display or seven-segment display (as in calculator). Our task is to calculate the possibility of occurrence of other timings that can occur by glowing or deleting one bit of the display.Seven-segment display is a special display that is used to display digits by glowing lines of the display.Sample of the seven-segment display is −Let’s take an example to understand the problem, Input − 7 5Output −Explanation − For 7, 5 numbers can be used to replace it. They are 9, 3, 8, 0, 7. For 5, 4 numbers ...

Read More

Possible number of Rectangle and Squares with the given set of elements in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 406 Views

In this problem, we are given an array of N integers denoting the length of n sticks. Our task is to print the count of rectangles and squares that can be created from the sticks of the given length.Let’s take an example to understand the problemInput − array = {5, 5, 7, 7, 1, 4}Output − 1Explanation − a rectangle with sides 5 5 7 7.To solve this problem, we will have to check if rectangles and squares are possible or not.Now, for creating a square or rectangle, there should be two sticks of the same length, 2 for rectangle and 4 for ...

Read More

Possible moves of knight in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 1K+ Views

In this problem, we are given an m*n chessboard with filled positions marked by 1 i.e. if board[i][j] = 1, there is some piece there and we are given the starting position. Our task is to find the total number of possible moves for a knight in the board, if there are all pieces of the same color i.e. no attack will be done.Knight is chess is a piece that can move in all directions with some special sort of move. The moves of Knight in chess are −Two horizontal moves and a vertical move.Two vertical moves and a horizontal ...

Read More

Possible cuts of a number such that maximum parts are divisible by 3 in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 222 Views

In this problem, we are given a large integer value (with up to 105 digits). Our task is to print the total number of cuts required such that maximum parts are divisible by 3.Let’s take an example to understand the problemInput − 9216Output − 3Explanation − the number is divided as 9|21|6.To solve this problem, we will have to start for the least significant bit of the number i.e. the last digit of the number. For here, we will find the smallest number divisible by three. And then update count based on it.Example − if arr[i] makes a 3 divisible ...

Read More

Possibility of moving out of maze in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 339 Views

In this problem, we are given a maze of n integers, each integer indicates the number of moves to be done. Along with the direction indicated using ‘>’ and ‘ < > >Output − YESExplanation − moving from start, we will move 2 positions ahead, then 1 position ahead, then 4 positions ahead. This will move our of the maze.To solve this problem, we will check whether moving out of the maze is possible or not. For this either we need to go below 0 or above n. Starting from 0, we will process the direction based on the sign ...

Read More

Possibility of a word from a given set of characters in C++

sudhir sharma
sudhir sharma
Updated on 11-Mar-2026 217 Views

In this problem, we are two string str1 and str2. Our task is to check whether all characters of str2 and present in str1.Let’s take an example to understand the problemInput −str1 = “Hello” str2 = “Hell”Output − yesExplanation − all characters of str2 are present in str1.To solve this problem, a simple solution will be checking each character of str2 in str1 and then returning the solution.But we need to create effective solutions. So, we will use a frequency array (length 256 for all valid characters) and then traverse str1 and increase the value in frequency array based on ...

Read More
Showing 2001–2010 of 5,962 articles
« Prev 1 199 200 201 202 203 597 Next »
Advertisements