Arnab Chakraborty has Published 4293 Articles

Find the Smallest Divisor Given a Threshold in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:29:56

727 Views

Suppose we have an array of integers called nums and an integer k, that is threshold value, we will choose a positive integer divisor and divide all the array by it and sum the result of the division. We have to find the smallest divisor such that the result mentioned ... Read More

Group the People Given the Group Size They Belong To in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:27:05

389 Views

Suppose there are n people whose IDs are in range 0 to n - 1 and each person belongs exactly to one group. We have the array groupSizes of length n. This array is indicating that the group size each person belongs to, we have to find the groups there ... Read More

Count Square Submatrices with All Ones in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:23:44

186 Views

Suppose we a binary matrix, of size m x n. We have to count number of square submatrices, with all 1s. So if the matrix is like −011111110111So there will be 15 squares. 10 squares of single ones, 4 squares of four ones, and 1 square with nine ones.To solve ... Read More

Number of Burgers with No Waste of Ingredients in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:03:33

308 Views

Suppose we have two integers tomatoSlices and cheeseSlices. These are the ingredients of different burgers −Jumbo Burger: 4 tomato slices and 1 cheese slice.Small Burger: 2 Tomato slices and 1 cheese slice.We have to find [total_jumbo, total_small] so that the number of tomatoSlices that are left is equal to 0 ... Read More

Greatest Sum Divisible by Three in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 12:01:29

455 Views

Suppose we have an array nums of integers, we need to find the maximum possible sum of elements of the given array such that it is divisible by three. So if the input is like [3, 6, 5, 1, 8], then the output will be 18, as the subarray is ... Read More

Smallest Common Region in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:59:13

187 Views

Suppose we have some lists of regions where the first region of each list includes all other regions in that list. basically, if a region X contains another region Y then, X is larger than Y. Also by definition a region X contains itself. So if we have two regions ... Read More

Encode Number in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:55:40

577 Views

Suppose we have a non-negative integer n, and we have to find the encoded form of it. The encoding strategy will be as follows −NumberEncoded number0“”1“0”2“1”3”00”4”01”5”10”6”11”7”000”So if the number is 23, then result will be 1000, if the number is 54, then it will be 10111To solve this, we will ... Read More

Reconstruct a 2-Row Binary Matrix in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:51:17

227 Views

Suppose we have the following details of a matrix with n columns and 2 rows −Matrix elements will be either 0 or 1Sum of elements of the 0-th(upper) row is given as upper.Sum of elements of the 1-st(lower) row is given as lower.Sum of elements in the i-th column(0-indexed) is ... Read More

Maximum Length of a Concatenated String with Unique Characters in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:36:35

424 Views

Suppose we have an array of strings arr. The string s is a concatenation of a sub-sequence of arr which have unique characters. Find the maximum possible length of s. If the input is like [“cha”, “r”, “act”, “ers”], then the output will be 6, possible solutions are “chaers” and ... Read More

Circular Permutation in Binary Representation in C++

Arnab Chakraborty

Arnab Chakraborty

Updated on 02-May-2020 11:32:16

239 Views

Suppose we have 2 integers n and start. Our task is return any permutation p of (0, 1, 2....., 2^n -1) as follows −p[0] = startp[i] and p[i+1] differ by only one bit in their binary representation.p[0] and p[2^n -1] must also differ by only one bit in their binary ... Read More

Advertisements