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
Server Side Programming Articles - Page 799 of 2650
130 Views
Suppose we have an array A with first n natural numbers, and one permutation P{p1, p2, ... pn} of array A. We have to check how many magic sets are there. A permutation is said to be magic set, if this satisfies these few rules −If we have k, then the elements in positions a[1], a[2], ... a[k] are less than their adjacent elements [P[a[i] - 1] > P[a[i]] < P[a[i] + 1]]If we have l, then the elements in positions b[1], b[2], ... b[l] are greater than their adjacent elements [P[b[i] - 1] < P[b[i]] > P[b[i] + 1]]So, ... Read More
370 Views
Suppose we have an array A with first n natural numbers. We have to find how many sequences (S1) can we get after exact k adjacent swaps on A? And how many sequences (S2) can we get after at most k swaps on A? Here the adjacent swap means swapping elements at index i and i+1.So, if the input is like n = 3 k = 2, then the output will be 3, 6 because −Original array was [1, 2, 3]After 2 adjacent swaps: we can get [1, 2, 3], [2, 3, 1], [3, 1, 2] So S1 = 3After ... Read More
248 Views
Suppose there are n candles which are aligned from left to right. The i-th candle from the left side has the height h[i] and the color c[i]. We also have an integer k, represents there are colors in range 1 to k. We have to find how many strictly increasing colorful sequences of candies are there? The increasing sequence is checked based on heights, and a sequence is said to be colorful if there are at least one candle of each color in range 1 to K are available. If the answer is too large, then return result mod 10^9 ... Read More
497 Views
Suppose there are n cities numbered from 0 to n-1 and there are n directed roads. We can travel from city i to city (i + 1) % n [0 to 1 to 2 to .... to N - 1 to 0]. We have a car. The capacity of our car's fuel tank is cap unitss. There are fuel[i] units of fuel we can use at the beginning of city i and the car takes cost[i] units of fuel to travel from city i to (i + 1) % n. We have to find how many cities are there from ... Read More
133 Views
Suppose there are N number of robbers are trying to rob a vault. There was a guard but he went out for G amount of time, after that he will come back. And each robber has specific time to rob the vault, but at most two of them can enter into the vault at the same time. Now the problem is we have to check whether they can rob the vault of getting caught by the guard? We have to keep in mind that −If one robber goes inside the vault at a time t and at the same time ... Read More
259 Views
Suppose Amal and Bimal are playing a game. They have an array nums which determines n bricks with numbered on top of it. In this game, players can alternatively remove one, two or three bricks from the top, and the numbers marked on the removed bricks are added to the score of that player. If always Amal starts first, we have to find how much score Amal get secure at maximum.So, if the input is like nums = [1, 2, 3, 4, 5], then the output will be 6 because, Amal can remove brick {1}, {1, 2} or {1, 2, ... Read More
225 Views
Suppose Amal and Bimal are playing a game where they have one array A with some numbers.The game rules are as followsBimal will start alwaysIn each turn one player deletes the maximum element from the array and all other elements present at right of the deleted element will also be deleted.They play alternativelyThe player who removes all remaining elements, he will win the game.So, if the input is like nums = [5, 2, 6, 3, 4], then the output will be Amal because at first Bimal will remove [6, 3, 4] so array will be [5, 2], then Amal will ... Read More
188 Views
Suppose we have two values n and m. We have to find number of possible arrangements of humble matrices of order n x m. A matrix is said to be humble whenIt contains each element in range 1 to n x m exactly oncefor any two indices pairs (i1, j1) and (i2, j2), if (i1 + j1) < (i2 + j2), then Mat[i1, j1] < Mat[i2, j2] should hold.If the answer is too large then return result mod 10^9 + 7.So, if the input is like n = 2 m = 2, then the output will be 2, because there ... Read More
318 Views
Suppose, there is n number of cities and m roads connecting the cities. The citizens of the people need markets where they can buy their commodities. Now, there are no markets in the cities, and the roads between the cities are under construction.A two-way road can be built between two cities if (i) The city contains a market; (ii) The cities can be visited by the road where there is a market. The cost of building a road is x, and building a market is y and they are given. We have to find out the minimal cost to provide ... Read More
191 Views
Suppose, we have a tree that has all of its nodes numbered as 1 to n. Each of the nodes contains an integer value. Now if we remove an edge from the tree, the difference in the sum of the node values of the two sub-trees has to be minimal. We have to find out and return the minimum difference between such sub-trees. The tree is given to us as a collection of edges, and the values of the nodes are also provided.So, if the input is like n = 6, edge_list = [[1, 2], [1, 3], [2, 4], [3, ... Read More