
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

234 Views
In this problem, we are given two numbers n and d. Our task is to Find the minimum possible digit sum after adding a number d.Problem Description − we need to minimise the digits sum by adding kth multiple of d to n.Let’s take an example to understand the problem, Inputn = 5230, d = 54Output1ExplanationThe number will be 5230 + (2*54) = 5338Solution ApproachA simple approach to solve the problem would be to check all multiples of d from 1 to 8, as at 9th multiple the sum of digits will repeat. This is based on modulo 9, which ... Read More

585 Views
In this problem, we are given a binary array bin[] consisting n binary values which happen to be 0 and 1. Our task is to find minimum operations needed to make an Array beautiful.Beautiful array is a special type of binary array which consists of a pattern of alternate 0’s and 1’s.Problem Description − We need to find the number operations that are required to make the array beautiful. An operations consists of these steps −Step 1 − Cut the array into two halves.Step 2 − Reverse any one of the two halves.Step 3 − Join then halves back.We will ... Read More

872 Views
In this problem, we are given an array arr[] consisting of n positive numbers. Our task is to Find minimum number of merge operations to make an array palindrome.Palindrome array are similar to palindrome strings, the elements at index i and n-i should be the same.Example{5, 1, 7, 2, 7, 1, 5}Problem Description − We need to make the array palindrome by performing operations on it. And the only operation which is valid on the array is the merge operation in which we will add elements at index i and i+1.We need to return the minimum number of such operations ... Read More

203 Views
In this problem, we are given an array arr[] consisting of n positive elements. Our task is to find minimum in an array without using Relational Operators.Relational operators in programming are those operators which are used to check the relationship between two values. Like == (equals), greater than (>), less than (

476 Views
In this problem, we are given a binary tree. Our task is to Find Minimum Depth of a Binary Tree.Binary Tree has a special condition that each node can have a maximum of two children.The minimum depth of a binary tree is the shortest path between the root node to any leaf node.Let’s take an example to understand the problem, InputOutput2Solution ApproachThe solution to the problem is by traversing the binary tree and counting the heights. This can be done by recursively calling for the child node of the node for each node non-leaf node and return 1 for each ... Read More

173 Views
In this problem, we are given an array arr[] of size m representing the lengths of line segments.The line segments are from 0 to arr[0] , arr[0] to arr[1] and so on. Our task is to find the segment which is at the middle of all segments.Let’s take an example to understand the problem, Inputarr[] = {5, 7, 13}Output3ExplanationSegments are : (0, 5) , (5, 12), (12, 25)Solution ApproachTo solve the problem, we will find the middle point of the line by (arrSum/2). If this middle point is a starting or ending point of a line segment then print -1. ... Read More

288 Views
In this problem, we are given a 2D array mat[r][c] whose elements are sorted row-wise. Our task is to Find median in a row-wise sorted matrix.Description − we need to find the median of elements of the matrix.Let’s take an example to understand the problem, Inputmat = { {2, 4, 7}, {5, 6, 8}, {4, 8, 9} }Output6ExplanationThe elements of the matrix stored in array are &minus{2, 4, 4, 5, 6, 7, 8, 8, 9} The median is 6.Solution ApproachA simple solution to the problem is by storing all elements of the array. Then finding the median ... Read More

168 Views
In this problem, we are given an array arr[] of size n and an integer m. Our task is to Find mean of subarray means in a given array.Code Description − Here, we need to find the mean of array as the mean of means of subarray of size m.Let’s take an example to understand the problem, Inputarr[] = {2, 5, 3, 6, 1}, m = 3Output3.78ExplanationAll subarrays of size m are {2, 5, 3}, {5, 3, 6}, {3, 6, 1} Means of means of subarray of size m, $$(\left(\frac{2+5+3}{3}\right)+\left(\frac{5+3+6}{3}\right)+\left(\frac{3+6+1}{3}\right))/3=\left(\frac{10}{3}\right)+\left(\frac{14}{3}\right)+\left(\frac{10}{3}\right)/3=34/3/3=3.78$$Solution ApproachA simple solution to the problem is by finding all ... Read More

547 Views
In this problem, we are given an array arr[] consisting of n elements and an integer k. Our task is to find the Maximum XOR value of a sub-array of size k.Let’s take an example to understand the problem, Inputarr[] = {3, 1, 6, 2 ,7, 9} k = 3Output12ExplanationAll subarray and the xor of all element of size k, {3, 1, 6} = 4 {1, 6, 2} = 5 {6, 2, 7} = 3 {2, 7, 9} = 12Solution ApproachA simple solution to the problem is by using two loops. One to iterate over the array and other to ... Read More

187 Views
In this problem, we are given Q queries each of which is one of the following type, Type 1 − insertion (1, i) to add the element with value i, in your data structure.Type 2 − findXOR (2, i), to find the XOR of all elements of the data structure with the element i.The data structure should contain only 1 element initially which will be 0.Let’s take an example to understand the problem, InputQueries: (1, 9), (1, 3), (1, 7), (2, 8), (1, 5), (2, 12)Output15 15ExplanationSolving each query, (1, 9) => data structure => {9} (1, 3) => data ... Read More