
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++

1K+ Views
In this problem, we are given a binary array bin[] consisting of only 0’s and 1’s. Our task is to find the number of zeroes.The array is sorted i.e. all 0’s are arranged together after 1’s.Let’s take an example to understand the problem, Inputarr[] = {1, 1, 1, 0, 0, 0, 0}Output4Solution ApproachA simple solution to the problem is using the fact that the array is sorted, that is the number of 0’s in the array can be found using the first occurrence of 0 in the array. As after the first occurrence all values will be zero.For finding the ... Read More

288 Views
In this problem, we are given a number N denoting the number of bricks provided to create the stair. Our task is to find the number of stair steps.Using the given bricks, we need to create a stair step. Each step takes one more brick that the last step. And the first step is two bricks high. We need to find the number of such steps that can be made from bricks.Let’s take an example to understand the problem, InputN = 40Output3ExplanationStep = 1 ; bricks required = 2; total bricks used = 2 ; bricks remaining = 38Step = ... Read More

452 Views
In this problem, we are given three integer values A, B, C. Our task is to find the number of solutions to the given equation.EquationX = B*Sm(X)^A + Cwhere Sm(X) is the sum of digits of X.We need to count all the values of X such that it satisfies the above equation where X can be any number between 1 to 109.Let’s take an example to understand the problem, InputA = 3, B = 6, C = 4Output3Solution ApproachA solution to solve the problem is by counting the number of values of X. For this, the sum of digits plays ... Read More

566 Views
In this problem, we are given a 2D binary matrix. Our task is to find the number of islands Using DFS.Island is a ground of 1 or more connected 1’s in the matrix.Let’s take an example to understand the problem, Inputbin[][] = {{ 1 0 0 0} {0 1 0 1} {0 0 0 0} {0 0 1 0}}Output3 ExplanationIslands are : bin00 - bin11 bin13 bin32Solution ApproachTo find the island from a binary matrix using a disjoint set data structure. To find island count, we will traverse the matrix and do union of ... Read More

325 Views
In this problem, we are given a 2D binary matrix. Our task is to Find the number of islands Using DFS.Island is a ground of 1 or more connected 1’s in the matrix.Let’s take an example to understand the problem, Input : bin[][] = {{ 1 0 0 0} {0 1 0 1} {0 0 0 0} {0 0 1 0}} Output : 3 ExplanationIslands are −bin00 - bin11bin13bin32 Solution ApproachTo solve the problem using DFS, we will use the DFS technique for exploring all the neighbours (maximum possible 8 of a number in the matrix) and ... Read More

602 Views
In this problem, we are given an integer value N. Our task is to find Nth Even Fibonacci Number.Fibonacci Series generates subsequent number by adding two previous numbers. The Fibonacci series starts from two numbers − F0 & F1. The initial values of F0 & F1 can be taken 0, 1 or 1, 1 respectively.Let’s take an example to understand the problem, Input : N = 4 Output : 144Solution ApproachA simple solution to the problem is using the fact that every third number in the fibonacci sequence is even and the sequence of even numbers also follows the recursive ... Read More

228 Views
In this problem, we are given string str[] of size N and an integer X. Our task is to create a program to print First X vowels from a string.We will print first X vowels from the string and if less than X vowels are present, print -1.Let's take an example to understand the problem, Input: str = "learn C programming language", X = 5 Output: e, a, o, a, i Vowels are a, e, i, o, uSolution ApproachA simple solution to the problem is by traversing the string character by charter. And storing all the vowels of the string ... Read More

188 Views
In this problem, we are given an array of string str[] of size N. Our task is to create a program for finding the first string from the given array whose reverse is also present in the same array.Let's take an example to understand the problem, Input: str[] = ["python", "program", "C#", "language", "#C"] Output: C#Solution ApproachOne way to solve the problem is by directly traversing each element of the string array and checking for revere of the string in the remaining array. Return the string if the reverse is found. If the whole array is traversed and no string ... Read More

223 Views
In this problem, we are given a linked list LL of size N. Our task is to create a program for finding non-repeating in linked list.Linked list is a sequence of data structures, which are connected together via links.Let's take an example to understand the problem, Input: LL = 4 => 6 => 2 => 4 => 1 => 2 => 6 => 5 Output: 1Explanation −The elements with a single occurrence frequency are 1 and 6. Out of these 1 occurred first in the linked list. Solution ApproachAn approach to solve the problem is by creating a hash table ... Read More

1K+ Views
In this problem, we are given an array arr[] consisting of N integer values and a window of size N. Our task is to create a program for finding the first negative integer in every window of size k. We will be printing the first negative number if it exists otherwise print 0, denoting no negative exists.Let's take an example to understand the problem, Input: arr[] = {-2, 2, -1, 4, 3, -6}, k = 2 Output: -2, -1, -1, 0, -6Explanation −Size of window k = 2, {-2, 2}, first negative is -2 {2, -1}, first negative is -1 ... Read More