
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 33676 Articles for Programming

423 Views
ConceptWith respect of a given array of positive integers, we replace each element in the array so that the difference between adjacent elements in the array is either less than or equal to a given target. Now, our task to minimize the adjustment cost, that is the sum of differences between new and old values. So, we basically need to minimize Σ|A[i] – Anew[i]| where 0 ≤ i ≤ n-1, n is denoted as size of A[] and Anew[] is denoted as the array with adjacent difference less than or equal to target. Let all elements of the array is ... Read More

204 Views
Suppose we have a RAM and that RAM is organized in blocks. there are multiple processes running on the system. We have to keep in mind that every process gets following information, (Thread T, Memory Block M, time t, R/W) This indicates the thread T was implementing memory block M at given time t and operation could be either read(R) or write(W).The following case is indicating whether it is memory conflict or not −More than one read operations at the same location are not the reason of conflict.When writing operation is being performed between x+5 to x-5 to location of ... Read More

898 Views
ConceptWith respect of a given Binary Search Tree(BST), our task is to determine median of it.For even no. of nodes, median = ((n/2th node + (n+1)/2th node) /2 For odd no. of nodes, median = (n+1)/2th node.For given BST(with odd no. of nodes) is − 7 / \ 4 9 / \ / \ 2 5 8 10Inorder of Given BST will be : 2, 4, 5, 7, 8, 9, 10 So, here median will 7.For given BST(with even no. of nodes) is − 7 ... Read More

2K+ Views
In this article, we have an array of positive integers of size n. Our task is to calculate the maximum sum of triplet ( ai + aj + ak ) such that 0 sum = 12 3 6 10 => sum = 19 3 4 10 => sum = 17 4 5 10 => sum = 19 2 5 10 => sum = 17 Maximum sum = 19 Finding maximum sum of triplets in an array such than i < j < k and a[i] < a[j] < a[k]Here are the approaches ... Read More

144 Views
ConceptWith respect of a given array A having N elements and two integers l and r where, 1≤ ax ≤ 105 and 1≤ l≤ r≤ N. We can select any element of the array (let’s say ax) and delete it, and also delete all elements equal to ax+1, ax+2 … ax+R and ax-1, ax-2 … ax-L from the array. This step will cost ax points. Our task is to maximize the total cost after deleting all the elements from the array.Input2 1 2 3 2 2 1 l = 1, r = 1Output8Here, we choose 2 to delete, then (2-1)=1 ... Read More

132 Views
ConceptWith respect of given two numbers P and Q ( P and Q can be up to 10^6 ) which forms a number N = (P!/Q!). Our task is to reduce N to 1 by performing maximum number of operations possible. Remember, in each operation, one can replace N with N/X if N is divisible by X. Determine the maximum number of operations that can be possible.InputA = 7, B = 4Output4ExplanationN is 210 and the divisors are 2, 3, 5, 7InputA = 3, B = 1Output2ExplanationN is 6 and the divisor are 2, 3.MethodIt has been observed that factorization ... Read More

467 Views
ConceptWith respect of a given integer X, our task is to determine the maximum value N so that the sum of first N natural numbers should not exceed X.InputX = 7Output22 is the maximum possible value of N because for N = 3, the sum of the series will exceed X i.e. 1^2 + 2^2 + 3^2 = 1 + 4 + 9 = 14InputX = 27Output33 is the maximum possible value of N because for N = 4, the sum of the series will exceed X i.e. 1^2 + 2^2 + 3^2 + 4^2 = 1 + 4 + ... Read More

317 Views
ConceptWith respect of a given grid of numbers, determine maximum length Snake sequence and display it. It has been observed that if multiple snake sequences exist with the maximum length, display any one of them.Actually, a snake sequence is made up of adjacent numbers in the grid so that for each number, the number on the right or the number below it is either +1 or -1 its value. Here, for instance, if we are at location (a, b) in the grid, we can either move right i.e. (a, b+1) if that number is ± 1 or move down i.e. ... Read More

454 Views
ConceptWith respect of the given number of cities N numbered from 0 to N-1 and the cities in which stations are located, our task is to determine the maximum distance between any city and its nearest station. It should be noted that the cities with stations can be given in any order.InputnumOfCities = 6, stations = [2, 4]Output2InputnumOfCities = 6, stations = [4]Output4The following figure indicates the first example containing 6 cities and the cities with stations highlighted with green color. So, in this case, the farthestcities from its nearest stations are 0 at a distance of 2. Hence maximum ... Read More

366 Views
ConceptWith respect of a given an array of integers, our task is to determine the maximum absolute difference between the nearest left and the right smaller element of every element in the array. It should be noted that if there is no smaller element on right side or left side of any element then we accept zero as the smaller element. Here, for example for the leftmost element, the nearest smaller element on the left side is set as 0. In the same way, for rightmost elements, the smaller element on the right side is set as 0.Inputarr[] = {3, ... Read More