Arnab Chakraborty

Arnab Chakraborty

3,768 Articles Published

Articles by Arnab Chakraborty

Page 36 of 377

C++ program to find in how many bases we can represent the number not greater than M

Arnab Chakraborty
Arnab Chakraborty
Updated on 03-Mar-2022 217 Views

Suppose we have a numeric string S, and another number M. Let d be the greatest digit in S. We have to find in many different integers not greater than M can be found by choosing an integer n not less than d+1 and seeing S as a base-n number?So, if the input is like S = "999"; M = 1500, then the output will be 3, because S as base 10 number, we get 999, as base 11 number, we get 1197, as base 12 number, we get 1413. These three values are the only ones that we can ...

Read More

C++ program to count final number of characters are there after typing n characters in a crazy writer

Arnab Chakraborty
Arnab Chakraborty
Updated on 03-Mar-2022 201 Views

Suppose we have an array A with n elements, and another value c is there. There is a crazy word processor present in our system where we can type characters but if we do not type for consecutive c seconds, all of the written letters will be removed. A[i] represents the time when we have typed the ith character. We have to find the final number of characters that will remain on the screen after typing all n characters.So, if the input is like A = [1, 3, 8, 14, 19, 20]; c = 5, then the output will be ...

Read More

C++ program to find longest possible time not greater than T to solve all problems

Arnab Chakraborty
Arnab Chakraborty
Updated on 03-Mar-2022 304 Views

Suppose we have an array A with N elements. Have another number T. Consider Amal is trying to participate in a programming contest. It lasts for T minutes and present N problems. He has A[i] time to solve ith problem. He will choose zero or more problems to solve from the N problems, so that it takes no longer T minutes in total to solve them. We have to find the longest possible time it will take to solve his choice of problems.So, if the input is like T = 17; A = [2, 3, 5, 7, 11], then the ...

Read More

C++ program to find minimum number of operations needed to make all cells at r row c columns black

Arnab Chakraborty
Arnab Chakraborty
Updated on 03-Mar-2022 315 Views

Suppose we have two numbers r, c and a grid of size n x m. Some cells are in black and remaining are white. In one operation, we can select some black cells and can do exactly one of these two −Color all cells in its row black, orcolor all cells in its column black.We have to find the minimum number of operations needed to make the cells in row r and column c black. If impossible, return -1.So, if the input is likeWBWWWBBBWBWWBBBr = 0 and c = 3then the output will be 1, because we can change the ...

Read More

C++ program to find maximum how many chocolates we can buy with at most k rupees

Arnab Chakraborty
Arnab Chakraborty
Updated on 03-Mar-2022 519 Views

Suppose we have an array A with n elements, and other values l, r and k are there. Amal wants to buy chocolates and he will not buy too expensive chocolates, and not also too cheap chocolates. In the store, there are n different chocolate bars and the prices are represented in A. A chocolate bar is too expensive if its price is larger than r and too cheap if its price is less than l. He wants to spend at most k rupees. We have to find the maximum amount of chocolates he can buy.So, if the input is ...

Read More

C++ program to count number of steps needed to make sum and the product different from zero

Arnab Chakraborty
Arnab Chakraborty
Updated on 03-Mar-2022 336 Views

Suppose we have an array A with n elements. In one operation, we can add 1 with any one element preset in A. If either the sum or the product of all elements in the array is equal to zero, We can do this operation one more time. We have to count the minimum number of steps needed to make both the sum and the product of all elements in the array different from zero?So, if the input is like A = [-1, 0, 0, 1], then the output will be 2, because both product and sum are 0. If ...

Read More

C++ program to find minimum number of punches are needed to make way to reach target

Arnab Chakraborty
Arnab Chakraborty
Updated on 03-Mar-2022 361 Views

Suppose we have a matrix containing H rows and W columns. The cells either holds '.' or '#'. The dot '.' indicates passable space, and '#' indicates block. Amal will go from his house to a market. His house is in the cell at the top-left corner, and the market is at the bottom-right corner. Amal can move one cell up, down, left, or right to a passable cell. He cannot leave the town. He cannot enter a blocked cell, either. However, his physical strength allows him to destroy all blocks in a square region with 2×2 cells of his ...

Read More

C++ program to find maximum profit we can make by making hamburger and chicken burgers

Arnab Chakraborty
Arnab Chakraborty
Updated on 03-Mar-2022 407 Views

Suppose we have five numbers b, p, f, h and c. There are two types of burgers in a restaurant. These are hamburger and chicken burger. Hamburger needs two buns and a beef patty and for chicken burger we need two buns and a chicken cutlet. We have b buns, p beef patties, f chicken cutlets. We are trying to sell hamburger for h rupees and chicken burger for c rupees. We have to find the maximum profit that we can gain.So, if the input is like b = 7; p = 5; f = 2; h = 10; c ...

Read More

C++ program to check we can place dominos on colored cells in correct order or not

Arnab Chakraborty
Arnab Chakraborty
Updated on 03-Mar-2022 207 Views

Suppose we have five numbers n, k1, k2, w and b. There is a board with 2 x n cells and first k1 cells in the first row, first k2 cells in second row are colored in white. All other cells are black. We have w white dominos and b black dominos (2 x 1 size). We can place a white domino on the board if both board's cells are white and not occupied by any other domino. In the same way, a black domino can be placed if both cells are black and not occupied by any other domino. ...

Read More

C++ program to find number of groups can be formed from set of programmers

Arnab Chakraborty
Arnab Chakraborty
Updated on 03-Mar-2022 494 Views

Suppose we have an array A with n elements. The A[i] represents the programming skill of ith student. All elements in A are distinct. We want to split them into teams in such a way that −No two students i and j, such that |A[i] - A[j]| = 1 belong to the same teamThe number of teams is the minimum possible.So, if the input is like A = [2, 3, 4, 99, 100], then the output will be 2, because the groups are [2, 3, 4] and [99, 100]StepsTo solve this, we will follow these steps −dem := 1 sort ...

Read More
Showing 351–360 of 3,768 articles
« Prev 1 34 35 36 37 38 377 Next »
Advertisements