Arnab Chakraborty has Published 4293 Articles

Minimum Number of Flips to Convert Binary Matrix to Zero Matrix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 11:33:59

176 Views

Suppose we have a m x n binary matrix mat. In one step, we can choose one cell and flip its bit and all the four neighbors of it if they are present. We have to find the minimum number of steps required to convert mat to a zero matrix. ... Read More

Palindrome Partitioning III in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 11:30:53

223 Views

Suppose we have a string s that is containing lowercase letters and an integer k. We have to maintain some properties. These are −First, we have to change some characters (if needed) of s to other lowercase English letters.Then divide the string s into k substrings such that each substring ... Read More

Race Car in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 11:27:33

1K+ Views

Suppose we have a car, that starts at position 0 and speed +1 on an infinite number line. The car runs automatically according to a sequence of instructions A: for accelerate and R − for reverse. When we get an instruction "A", our car does the following −position := position ... Read More

Bus Routes in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 11:25:11

1K+ Views

Suppose we have a list of bus routes. In each routes[i] there is a bus route that the i-th bus repeats forever. So, if routes[0] = [1, 5, 7], this means that the first bus (0-th indexed) travels in the sequence 1, 5, 7, 1, 5, 7, 1, ... forever.Now ... Read More

Chalkboard XOR Game in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 11:22:26

302 Views

Suppose we have an array called nums, where nums[i] are written on a chalkboard. Ram and Sam take turns erasing exactly one element from the chalkboard, with Ram starting first. If erasing a number causes the bitwise XOR of all the elements of the chalkboard to become 0, then that ... Read More

Split Array With Same Average in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 11:20:30

382 Views

Suppose we have one array A, we must move every element of A to either list B or list C. (These lists B and C are initially empty.) We have to check whether after such a move, it is possible that the average value of B is equal to the ... Read More

Smallest Rotation with Highest Score in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 11:18:15

157 Views

Suppose we have an array A, we may rotate it by a K so that the array becomes A[K], A[K+1], A{K+2], ... A[A.length - 1], A[0], A[1], ..., A[K-1]. Then, any entries that are less than or equal to their index are worth 1 point.So for example, let we have ... Read More

Preimage Size of Factorial Zeroes Function in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 11:15:02

218 Views

Suppose we have a function f(x), this will return the number of zeroes at the end of factorial of x. So for f(3) = 0 because 3! = 6 has no zeroes at the end, while f(11) = 2 because 11! = 39916800 has 2 zeroes at the end. Now ... Read More

K-th Smallest Prime Fraction in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 11:12:58

545 Views

Suppose we have one sorted list, there is 1 and some prime numbers, now for every p < q in the list, we will consider fraction p/q, then we have to find which is the kth smallest fraction. We have to return an array as answer, so ans[0] will be ... Read More

Transform to Chessboard in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-Jun-2020 11:09:24

520 Views

Suppose we have one N x N board contains only 0s and 1s. Now in each move, we can swap any 2 rows, or any 2 columns. We have to find the minimum number of moves to transform the board into a "chessboard". If the solution does not exist, then ... Read More

Advertisements