Arnab Chakraborty has Published 4293 Articles

Minimum Cuts can be made in the Chessboard such that it is not divided into 2 parts in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 06:45:17

228 Views

ConceptGiven A x B Chessboard, the task is to calculate the Maximum numbers of cuts that we can build in the Chessboard so that the Chessboard is not divided into 2 parts.Examples The examples are given below −Input A = 2, B = 4Output Number of maximum cuts = 3Input A = 2, B ... Read More

Minimum Cost to cut a board into squares in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 23-Jul-2020 06:42:24

396 Views

ConceptSuppose a board of length p and width q is given, we require to break this board into p*q squares such that cost of breaking is least. For this board, cutting cost for each edge will be given. In a nutshell, we require selecting such a sequence of cutting such ... Read More

Build Array Where You Can Find The Maximum Exactly K Comparisons in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 09:24:12

177 Views

Suppose we have three integers n, m, and k. If we have following algorithm to find the maximum element of an array of positive integers −max_val := -1 max_ind := -1 search_cost := 0 n := size of arr for initialize i := 0, when i < n, update (increase ... Read More

Number of Ways to Paint N × 3 Grid in C++ program

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 09:15:13

166 Views

Suppose we have a grid whose size is n x 3 and we want to paint every cell of the grid with exactly one of the three colors. Here the colors that will be used are Red, Yellow and Green.Now there is a constraint, that is no two adjacent cells ... Read More

The Maze III in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 09:13:05

506 Views

Suppose there is a maze with empty spaces and walls and there is also a ball in that maze. The ball can go through empty spaces by rolling up (u), down (d), left (l) or right (r) directions, but it keeps rolling until hitting a wall. When the ball stops, ... Read More

Substring with Concatenation of All Words in C++ Program

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 09:09:36

221 Views

Suppose we have a string, s, and we also have a list of words, words present in the array are all of the same length. We have to find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and without any ... Read More

Encode String with Shortest Length in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 09:06:42

671 Views

Suppose we have a non-empty string; we have to encode this string such that its encoded length will be minimum.The encoding rule is like − k[encoded_string], where the encoded_string inside [ ] is being repeated exactly k times. We have to keep in mind that k will be a positive ... Read More

Count The Repetitions in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 09:04:48

320 Views

Suppose we have two non-empty strings s1 and s2 (maximum 100 characters) and two numbers n1 and n2 both are in range 0 to 106. Now suppose the strings S1 and S2, where S1=[s1, n1] and S2=[s2, n2].S = [s, n] defines the string S which consists of n connected ... Read More

Optimal Account Balancing in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 09:02:52

525 Views

Suppose a group of friends went on holiday and sometimes they lent each other money. So as an example, Amit paid for Bikram's lunch for $10. Then later Chandan gave Amit $5 for a taxi fare. We have to design a model where each transaction is taken as a tuple ... Read More

LFU Cache in Python

Arnab Chakraborty

Arnab Chakraborty

Updated on 21-Jul-2020 09:00:43

2K+ Views

Suppose we want to design and implement a data structure for Least Frequently Used (LFU) cache system. It should support the following operations −get(key) – This will be used to get the value of the key if the key exists in the cache, otherwise return -1.put(key, value) – This will ... Read More

Advertisements