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
C++ Articles - Page 149 of 719
245 Views
In this problem, we are given an array arr[] of integer elements. Our task is to create a program to find the Floor of every element in the same array. If the floor of an element exists, we will print the floor otherwise print -1.Floor of an element in array is the closest element which is smaller than or equal to the element in the array.Let’s take an example to understand the problemInput: arr[] = {3, 1, 5 ,7, 8, 2} Output: 2 -1 3 5 7 1Solution ApproachAn approach to solve the problem is by using nested loops. One ... Read More
561 Views
In this problem, we are given a sorted array arr[] and an integer value x. Our task is to create a program to find the floor in a sorted array.Floor of X in sorted array arr is the largest element of the array arr[] which is smaller than or equal to x.Let’s take an example to understand the problemInput: arr[] = {2, 5, 6, 8, 9, 12, 21, 25}, x = 10 Output: 9Explanation − In the above array 9 is the largest number which is smaller than or equal to 10.Solution ApproachA simple solution to the problem is directly ... Read More
603 Views
In this problem, we are given a directed graph represented as an adjacency list. Our task is to create a program for finding the path from one vertex to rest using BFS.BFS(Breadth First Search) is an algorithm that traverses a graph in a breadthward motion and uses a queue to remember to get the next vertex to start a search, when a dead end occurs in any iteration.Let's take an example to understand the problem,Input −OutputSA
493 Views
In this problem, we are given a N*N matrix mat[]. Our task is finding the maximum square sub-matrix with all equal elements.In this problem, we need to find the maximum size of a sub-matrix from the given matrix whose all elements are the same.Let's take an example to understand the problem, Input: mat[][] = {{1, 2, 1}, {1, 2, 2}, {2, 2, 2}} Output: 2Explanation −matrix a11, a12, a21, a22 is of size 2X2 and forms a sub-matrix with all equal elements. Solution ApproachA simple solution to the problem is by traversing all the elements of the matrix and then ... Read More
677 Views
In this problem, we are given a positive integer N denoting the number of friends in a group. Our task is to create a program to solve the Friends Pairing Problem.Each friend of the group can either remain single or can pair up with one other friend. The pairing of each friend of the group can be done only once.Let’s take an example to understand the problemInput: n = 3 Output: 4 Explanation: Let’s say the 3 members of the group are A, B and C. The pairing can be done as : {A}, {B}, {C} {A, B}, {C} {A, ... Read More
608 Views
In this problem, we are given a number N. Our task is to finding n-th number made of prime digits (2, 3, 5 and 7) only.The series consisting of prime digits only (2, 3, 5, 7) is, 2, 3, 5, 7, 22, 23, 25, 27, 32, 33...Let's take an example to understand the problem, Input: N = 6 Output: 23Solution ApproachA simple approach to solving the problem is by finding the number at the given index i.e. by finding the term of the series, for this we will be observing the series.We have four different prime numbers so the series ... Read More
495 Views
In this problem, we are given a sorted linked list consisting of N elements. Our task is to finding Median in a Sorted Linked List.Sorted Linked List is a simple linked list in which all elements are sorted in a specific order. Example − 4 -> 6 -> 7 -> 9 -> NULLMedian is the middle elements of the linked list. It can be found as if N is odd : median is (n/2)th elementif N is even −s median is average of (n/2)th element and (n/2 + 1)th element.Let's take an example to understand the problem, Input: 2 -> ... Read More
3K+ Views
In this problem, we are given an 2D matrix mat[][]. Our task is to find inverse of a matrix using Gauss Jordan Method.Now, lets understand the basics of the problem, MATRIX is a two dimensional array of numbers.Example$\begin{bmatrix}2&5&4 \1&6&7 \9&3&8\end{bmatrix}$Inverse of Matrix [A-1] −It is an operation performed on square matrix. The following are the properties that are required for a matrix to have an inverse −Initial matrix should be square matrix.It must be non-singular matrix.An identity matrix I exist for the matrix A such that, $$AA^{-1} = A^{-1}.A = I$$Their is a formula that can be used to find ... Read More
838 Views
Format String − It is an ASCII string that is used for formatting strings. It is an ASCII string consisting of texts and formatting parameters.For formatting, the program’s output, there are various format strings in C.FORMAT STRING VULNERABILITIESThese are bugs that arise due to errors in programming that might be made easily by the programmer. If any such error-prone code blog is passed to output functions like printf, sprintf, etc. Then the write operation is performed to an arbitrary memory address.Example#include #include int main(){ char buffer[100]; strncpy(buffer, "Hii ", 5); printf(buffer); return 0; ... Read More
253 Views
In this problem, we are given a number N. Our task is to find the decimal conversion of the fist three and last three bits for the given integer values N.Let's take an example to understand the problem, Input : 57 Output : 71Solution ApproachA simple solution is by changing the number n into its binary equivalent and then saving the bits in an array. After this, we will convert the first three and last three values from the array into numbers individually. The decimal conversion of both the sets of bits is our result.For example, take the number 80.The ... Read More