Programming Articles - Page 938 of 3363

Program to check robbers can rob the vault or not in Python

Arnab Chakraborty
Updated on 23-Oct-2021 07:11:05

145 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

Program to find maximum score of brick removal game in Python

Arnab Chakraborty
Updated on 23-Oct-2021 07:03:30

272 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

Program to find winner of array removal game in Python

Arnab Chakraborty
Updated on 23-Oct-2021 07:00:23

234 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

Program to count number of possible humble matrices in Python

Arnab Chakraborty
Updated on 23-Oct-2021 06:56:58

200 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

Program to find out the minimal cost so that the citizens have access to a market in Python

Arnab Chakraborty
Updated on 23-Oct-2021 06:53:04

334 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

Program to find out the minimum value from sum of node values of sub-trees in Python

Arnab Chakraborty
Updated on 23-Oct-2021 06:46:22

205 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

Merge a linked list into another linked list at alternate positions in Java

Sunidhi Bansal
Updated on 22-Oct-2021 10:00:39

924 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

Memory representation of Binomial Heap in C++

Sunidhi Bansal
Updated on 22-Oct-2021 09:43:54

546 Views

What is a Binomial Tree?Binomial tree is an ordered tree data structure, let's say, B0 consists of a single node whereas a binomial tree represented as Bk consists of two binomial trees i.e. Bk-1 which are linked together. The root of one binomial tree is the leftmost child of the root of the other binomial tree. Binomial tree is mostly used for fundamental and technical analysing of assets or the stocks.The nodes of a binomial tree represent the intrinsic value of an asset. It helps investors or buyers of the markets to analyze the right time and value for investment.What ... Read More

Min-Max Range Queries in Array in C++

Sunidhi Bansal
Updated on 22-Oct-2021 09:42:24

1K+ Views

Given an array Arr[] containing N elements. The goal is to find the minimum and maximum value from indexes of query.According to the query we are given starting index and ending indexes.For ExampleIn − Arr[] = { 1, 2, 3, 4, 5 } QStart = 1 QEnd = 4Out −Minimum Value : 2Maximum Value : 5Explanation −In the above queries the starting index is 1 and ending index is 4. Between these two indexes, minimum value in Arr is 2 and maximum value is 5In − Arr[] = { 10, 12, 3, 2, 5, 18 } QStart = 2 QEnd = 5Out −Minimum Value : ... Read More

New feature of C++17

Sunidhi Bansal
Updated on 22-Oct-2021 09:07:35

1K+ Views

The C++ Standards committee is always focusing on shipping new features every three years. The two main parts of the specification are the core functionality of the programming language and the Standard Template Library (STL). The new features are introduced to make the code cleaner, easier and compact. Following is the list of features that are introduced-:1. Fold ExpressionsFold expressions are used to write shorter codes for a variable number of arguments that can be passed to a function or can be returned from the function. It enables the use of any number of variables as arguments and in return ... Read More

Advertisements