## Make The String Great Leetcode Solution

Problem Statement In “Make The String Great” problem a string is given consists of lower and upper case letters. We have to make this string good by removing adjacent characters in the string which is making the string bad. A good string is a string which doesn’t have two adjacent …

This post is on Lemonade Change Leetcode Solution Problem statement In the problem ” Lemonade Change” there is a queue of customers. They want to buy lemonade from us which costs 5 rupees. The customers can give us 5 rupees, 10 rupees, or 20 rupees. We want to return the …

## Find the Smallest Divisor given a Threshold Leetcode Solution

This post is on Find the Smallest Divisor given a Threshold Leetcode Solution Problem statement In the problem ” Find the Smallest Divisor Given a Threshold” we are given a nums array and a threshold value. A variable “result” is defined as the sum of all answers when elements in …

## Maximize Sum of Array after K Negations Leetcode Solution

This post is on Maximize Sum Of Array After K Negations Leetcode Solution Problem statement In the problem ” Maximize Sum Of Array After K Negations” we are given an array arr and a value K. The array consists of integer values. We can change the value of arr[i] to …

## Valid Perfect Square Leetcode Solution

This post is on Valid Perfect Square Leetcode Solution Problem statement In the problem “Valid Perfect Square” we are given a number “num” and we need to check if this number is a perfect square or not. We have to check this without using the built-in sqrt function. If the …

## Average Salary Excluding the Minimum and Maximum Salary Leetcode Solution

Problem statement In the problem ” Average Salary Excluding the Minimum and Maximum Salary” we are given a salary array. where each element in the array represents the salary of different employees. Each value in the array is unique. Our task is to calculate the average salary of the employee …

## Find First and Last Position of Element in Sorted Array Leetcode Solution

Problem statement In this article titled “Find First and Last Position of Element in Sorted Array Leetcode Solution,” we will discuss the solution to a leetcode problem. In the given problem we are given an array. We are also given a target element. Elements in the array are sequenced in …

## Count Negative Numbers in a Sorted Matrix LeetCode Solution

Problem statement In the problem “Count Negative Numbers in a Sorted Matrix” we are given a matrix of n rows and m columns. Elements are sorted in decreasing order both row-wise and column-wise. We need to find the total number of negative elements in the matrix. Example grid = [[8,3,2,-1],[4,2,1,-1],[3,1,-1,-2],[-1,-1,-2,-3]] …

## Painting Fence Algorithm

Problem Statement The “Painting Fence Algorithm” states that you are given a fence having some posts (some wooden pieces or some other pieces) and some colors. Find out the number of ways to paint the fence such that at most only 2 adjacent fences have the same color. Since this …

## Binomial Coefficient

Problem Statement Find the Binomial Coefficient for a given value of n and k. “In mathematics, the binomial coefficients are the positive integers that occur as coefficients in the binomial theorem. Commonly, a binomial coefficient is indexed by a pair of integers n ≥ k ≥ 0 and is written as ” – quoted from Wikipedia. Example n = 5, k …