Trapping Rain Water

In Trapping Rain Water problem we have given N non-negative integers representing an elevation map and the width of each bar is 1. We have to find the amount of water that can be trapped in the above structure. Example Let’s understand that by an example For the above elevation …

Read moreTrapping Rain Water

Jump Game

In jump game we have given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index. Example Input: arr = [2,3,1,1,4] …

Read moreJump Game

Combination Sum

In combination sum problem we have given an array of positive integers arr[] and a sum s, find all unique combinations of elements in arr[] where the sum of those elements is equal to s. The same repeated number may be chosen from arr[] an unlimited number of times. Elements …

Read moreCombination Sum

Maximum Subarray

In the Maximum Subarray problem we have given an integer array nums, find the contiguous sub array which has the largest sum and print the maximum sum subarray value. Example Input nums[] = {-2, 1, -3, 4, -1, 2, 1, -5, 4} Output 6 Algorithm The goal is to find …

Read moreMaximum Subarray

Sliding Window Maximum

In Sliding Window Maximum problem we have given an array nums, for each contiguous window of size k, find the maximum element in the window. Example Input nums[] = {1,3,-1,-3,5,3,6,7} k = 3 Output {3,3,5,5,6,7} Explanation Naive Approach for Sliding Window Maximum For every contiguous window of size k, traverse …

Read moreSliding Window Maximum

Delete And Earn

In delete and earn problem we have given an array nums, you may perform the following operation on the array elements. In one operation you can choose any array element(say nums[i]) and get points equal to that element and delete all the occurrences of (nums[i] – 1) and (nums[i] + …

Read moreDelete And Earn