## Combination Sum Leetcode Solution

The problem Combination Sum Leetcode Solution provides us an array or list of integers and a target. We are told to find the combinations that can be made using these integers any number of times that add up to the given target. So more formally, we can use the given …

## Island Perimeter Leetcode Solution

Problem Statement   In this problem, we are given a grid in form of a 2-D array. grid[i][j] = 0 represents there is water at that point and grid[i][j] = 1 represents land. Grid cells are connected vertically/horizontally but not diagonally. There is exactly one island (a connected component of land …

## Available Captures for Rook Leetcode Solution

Problem Statement   In this problem, we are given a 2-D matrix that represents a chessboard with a white rook and some other pieces on it. White’s Rook is represented by the character ‘R’. White’s bishops are represented by ‘B’ and black’s pawns are represented as ‘p’. The problem guarantees that …

## Maximum Subarray Leetcode Solution

Problem Statement   Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. Example nums = [-2,1,-3,4,-1,2,1,-5,4] 6 Explanation: [4,-1,2,1] has the largest sum = 6. nums = [-1] -1 Approach 1 (Divide and Conquer)   In this approach …

## Sort Array by Increasing Frequency Leetcode Solution

Problem Statement   Given an array of integers nums, sort the array in increasing order based on the frequency of the values. If multiple values have the same frequency, sort them in decreasing order. Example nums = [1,1,2,2,2,3] [3,1,1,2,2,2] Explanation: ‘3’ has a frequency of 1, ‘1’ has a frequency of …

## Number of Students Doing Homework at a Given Time Leetcode Solution

The problem Number of Students Doing Homework at a Given Time Leetcode Solution asks us to find the number of students working on their homework at a given time. The problem is very clear, the title itself is already able to explain the whole problem. We are given a query …

## Lucky Numbers in a Matrix Leetcode Solution

The Lucky Numbers in a Matrix Leetcode Solution problem asked us to find a lucky integer from the given matrix. A lucky integer is defined as a number that is the minimum among all other elements in its row and maximum among its column. So there may be more than …

## Find the Distance Value Between Two Arrays Leetcode Solution

The problem Find the Distance Value Between Two Arrays Leetcode Solution provides us two arrays arr1 and arr2. Along with the two arrays, we are provided with an integer n. Then the problem asks us to find the relative distance between the given two arrays. The relative distance is defined …

## Rank Transform of an Array Leetcode Solution

The problem Rank Transform of an Array Leetcode Solution provided us with an array of integers. The array or the given sequence is unsorted. We need to assign ranks to each integer in the given sequence. There are some restriction s for assigning the ranks. The ranks must start with …

## Decompress Run-Length Encoded List Leetcode Solution

The problem Decompress Run-Length Encoded List Leetcode Solution states that you are given an array or vector containing a sequence. The sequence has some specific representation. The input sequence is formed from another sequence. We will call that another sequence as the original sequence. As per which the input sequence …