
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 26504 Articles for Server Side Programming

338 Views
Problem statementA tree is always a Bipartite Graph as we can always break into two disjoint sets with alternate levels.In other words, we always color it with two colors such that alternate levels have same color. The task is to compute the maximum no. of edges that can be added to the tree so that it remains Bipartite Graph.ExampleTree edges are represented in vertex pairs as follows −{1, 2}{1, 3}{2, 4}{3, 5} then we need 2 more edges to keep it Bipartite GraphIn a coloring graph the graph {1, 4, 5} and {2, 3} from two different sets. Since, 1 ... Read More

357 Views
Problem statementGiven an integer N which represents the number of Vertices. The Task is to find the maximum number of edges possible in a Bipartite graph of N vertices.Bipartite GraphA Bipartite graph is one which is having 2 sets of vertices.The set are such that the vertices in the same set will never share an edge between them.ExampleIf N = 10 then there will be total 25 edges −Both sets will contain 5 vertices and every vertex of first set will have an edge to every other vertex of the second setHence total edges will be 5 * 5 = ... Read More

1K+ Views
In this problem, we are given two integers N and M, N is the number of people in group 1, and M is the number of people in group 2. Our task is to create a program to find the maximum number of 3-person teams formed from two groups.We will be creating teams of 3 people by selecting a person from these groups such that the maximum teams can be made. Each team must have at least one person from each group.Let’s take an example to understand the problem, Input − N = 5, M = 3Output − 2Explanation −The ... Read More

621 Views
In this problem, we are given an array, are of n elements. Our task is to create a program to find the maximum modulo of all pairs of array where arr[i] >= arr[j].Here, we have to find the maximum value of arr[i] % arr[j] where arr[i] >= arr[j].Let’s take an example to understand the problem, Input − arr[] = {3, 5, 9}Output − 4Explanation −All possible Pairs arr[i] and arr[j], 5, 3 => 5%3 = 2 9, 3 => 9%3 = 0 9, 5 => 9%5 = 4To solve this problem, a simple and direct approach will be run two ... Read More

349 Views
In this problem, we are given an array of characters. Our task is to create a program to print the maximum length of the subarray whose first and last elements are same in C++.Let’s take an example to understand the problem, Input − array = {‘t’, ‘u’, ‘t’, ‘o’, ‘r’, ‘i’, ‘a’, ‘l’, ‘s’, ‘p’, ‘o’, ‘i’, ‘n’, ‘t’ }Output − 14Explanation −The subarray {‘t’, ‘u’, ‘t’, ‘o’, ‘r’, ‘i’, ‘a’, ‘l’, ‘s’, ‘p’, ‘o’, ‘i’, ‘n’, ‘t’ } starts and ends with t.To solve this problem, we find the first and last occurrence a character in the array and ... Read More

3K+ Views
As we know that exception is something that refers to the interruption in the flow of program or application. This unwanted event is known as Exception and is generally gives the indication regarding something wrong within the code. Basically particularly in language C# an exception can be a System or an Application Level exception. So on the basisSr. No.KeySystem level exceptionApplication level exception1DerivationSystem exceptions are derived from the base class System.SystemException which in itself is a derived class of SystemException.On other hand Application-level exceptions are derived from the base class System.ApplicationException which is again a derived class of SystemException2OccurrenceIn general ... Read More

251 Views
Problem statementGiven a string comprising of ones and zeros. The task is to find the maximum length of the segments of string such that a number of 1 in each segment is greater than 0ExampleIf input string is “10111000001011” the answer will 12 as follows −First segment is of length 7 10111000001011Second segment is of length 5 10111000001011Total length is length of (segment 1 + segment 2) = (7 + 5) = 12AlgorithmIf start == n then return 0.Run a loop from start till n, computing for each subarray till n.If character is 1 then increment the count of 1 ... Read More

150 Views
Problem statementGiven lengths of n rods in an array. If any person picks any rod, half of the longest rod (or (max + 1) / 2 ) is assigned and remaining part (max – 1) / 2 is put back. It may be assumed that sufficient number of rods are always available, answer M queries given in an array q[] to find the largest length of rod available for qith person, provided qi is a valid person number starting from 1ExampleInput : a[] = {6, 5, 9, 10, 12} q[] = {1, 3} Output : 12 9 The first ... Read More

122 Views
Problem statementGiven an array arr[] of N elements (0 ≤ arr[i] ≤ 1000). The task is to find the maximum length of the sub-array that contains only ugly numbers.Ugly numbers are numbers whose only prime factors are 2, 3 or 5.For Example below are the few number from series: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, …ExampleIf input array is {1, 2, 7, 9, 120, 810, 374} then answer is 3 as −Longest possible sub-array of ugly number sis {9, 120, 810}AlgorithmTake a unordered_set, and insert all the ugly numbers which are less than 1000 in ... Read More

135 Views
Problem statementGiven an array, we need to find the maximum height of the triangle which we can form, from the array values such that every (i+1)th level contain more elements with the larger sum from the previous level.ExampleIf input array is {40, 100, 20, 30 } then answer is 2 as −We can have 100 and 20 at the bottom level and either 40 or 30 at the upper level of the pyramidAlgorithmOur solution just lies on the logic that if we have maximum height h possible for our pyramid then ( h * (h + 1) ) / 2 ... Read More