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
 
Programming Articles - Page 938 of 3366
 
			
			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
 
			
			189 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
 
			
			911 Views
We are given two data structures as linked list Let’s say, List_1 and List_2. The task is to merge the elements of linked list ‘List_2’ into the linked list ‘List_1’ at an alternate position and if we are left with the elements which can't be merged into ‘List_1’ then it will be printed as the ‘List_2’ remaining elements.For Example-:In −List_1 =List_2 =Out − Merged List is-:Explanation − we are given with two lists i.e. List_1 and List_2. We had merged the possible elements of list_2 into List_1 at alternate positions. So, elements after merging in List_1 are 10- >3->2->1->1->4->2->5->5 and in List_2 are ... Read More