## Number of Submatrices That Sum to Target in C++ Published on 04-Jun-2020 14:38:36
Suppose we have a matrix, and a target value, we have to find the number of non-empty submatrices that sum is same as target. Here a submatrix [(x1, y1), (x2, y2)] is the set of all cells matrix[x][y] with x in range x1 and x2 and y in range y1 ... Read More

## Longest Duplicate Substring in C++ Published on 04-Jun-2020 14:35:18
Suppose we have a string S, consider all duplicated contiguous substrings that occur 2 or more times. (The occurrences may overlap.), We have to find the duplicated substring that has the longest possible length. If there is no such substrings, then return a blank string. As the answer may very ... Read More

## Escape a Large Maze Python Published on 04-Jun-2020 14:28:44
Suppose we have a grid, there are 1 million rows and 1 million columns, we also have one list of blocked cells. Now we will start at the source square and want to reach the target square. In each move, we can walk to a up, down, left, right adjacent ... Read More

## Stream of Characters in C++ Published on 04-Jun-2020 14:25:49
Suppose we want to implement the StreamChecker class as follows −StreamChecker(words) − This is the constructor, this initializes the data structure with the given words.query(letter) − This returns true when for some k >= 1, the last k characters queried (in order from oldest to newest, including this letter just ... Read More

## Numbers With Repeated Digits in C++ Published on 04-Jun-2020 14:22:10
Suppose we have a positive integer N, we have to find the number of positive integers less than or equal to N that have at least 1 repeated digit .So, if the input is like 99, then the output will be 9, as we have numbers like 11, 22, 33, ... Read More

## Grid Illumination in Python Published on 04-Jun-2020 13:25:04
Suppose we have a N x N grid of cells, in each cell (x, y) there is a lamp. Initially, some of the lamps are on. The lamps[i] is the location of the i-th lamp that is on. Each lamp that is on glows every square on its x-axis, y-axis, ... Read More

## Minimum Cost to Merge Stones in C++ Published on 04-Jun-2020 13:19:21
Suppose we have N piles of stones arranged in a row. Here the i-th pile has stones[i] number of stones. A move consists of merging K consecutive piles into one pile, now the cost of this move is equal to the total number of stones in these K number of ... Read More

## Number of Squareful Arrays in C++ Published on 04-Jun-2020 13:17:27
Suppose we have an array A of positive integers, we can say that array is squareful if for every pair of adjacent elements, their sum is a perfect square. We have to find the number of permutations of A that are squareful. Two permutations A1 and A2 will not be ... Read More

## Minimum Number of K Consecutive Bit Flips in C++ Published on 04-Jun-2020 13:15:33
Suppose we have an array A. This is containing only 0s and 1s, here a K-bit flip consists of choosing a (contiguous) subarray of length K and simultaneously inverting the bits n the subarray. We have to find the minimum number of K-bit flips required so that there is no ... Read More

## Subarrays with K Different Integers in C++ Published on 04-Jun-2020 13:13:43
Suppose we have an array A of positive integers, we can call a good subarray (contiguous) of A, if the number of different integers in that subarray is exactly K. So, if the array is like [1, 2, 3, 1, 2] has 3 different integers: 1, 2, and 3. We ... Read More
Previous 1 ... 3 4 5 6 7 8 9 ... 3598 Next