## 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 …

## Is Subsequence Leetcode Solution

Problem Statement   In this problem, we are given two different strings. The goal is to find out whether the first string is a subsequence of the second. Examples first string = “abc” second string = “mnagbcd” true first string = “burger” second string = “dominos” false Approach(Recursive)   This is easy …

## Pascal’s Triangle II Leetcode Solution

Problem Statement   In this problem we have been given Row index(i) of the Pascal Triangle. We have to create a linear array containing the values of the ith row and return it. Row index starts from 0. We know that Pascal’s triangle is a triangle where each number is the …

## Unique Paths Leetcode Solution

The problem Unique Paths Leetcode Solution states that you are given two integers representing the size of a grid. Using the size of the grid, the length, and breadth of the grid. We need to find the number of unique paths from the top left corner of the grid to …

## N-th Tribonacci Number Leetcode Solution

Problem statement   In the problem ” N-th Tribonacci Number” we are given a number n. Our task is to find out the N-th tribonacci number. The zeroth tribonacci number is 0. The first tribonacci number is 1. The second tribonacci number is 1. N-th tribonacci number is summation of (N-1- …

## House Robber II Leetcode Solution

In the “House Robber II” problem, a robber wants to rob money from different houses. The amount of money in the houses is represented through an array. We need to find the maximum sum of money that can be made by adding the elements in a given array according to …

## Minimum Score Triangulation of Polygon Leetcode Solution

Problem statement   In the problem ” Minimum Score Triangulation of Polygon” we are given a value array where each element in the array represents the value of a N-sided polygon when labeled in a clockwise direction. Our task is to triangulate the polygon into N-2 triangles. The score to triangulate …

## House Robber Leetcode Solution

Problem Statement   In this problem there are houses in a street and House robber has to rob these houses. But the problem is that he can’t rob more than one house successively i.e which are adjacent to each other. Given a list of non-negative integers representing the amount of money …

## Scramble String

Problem Statement   “Scramble String” problem states that you are given two strings. Check if the second string is a scrambled string of first one or not? Explanation Let string s = “great” Representation of s as binary tree by recursively dividing it into two non-empty sub-strings. This string can be …

## Unique Paths II

Suppose a man standing in the first cell or the top left corner of “a × b” matrix. A man can move only either up or down. That person wants to reach his destination and that destination for him is the last cell of the matrix or bottom right corner. …