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 …

Read more

How Many Numbers Are Smaller Than the Current Number Leetcode Solution

Problem Statement In this problem, we are given an array. For each element of this array, we have to find out the number of elements smaller than that element. i.e. for each i (0<=i<arr.length) we have to find out count of elements less than the number arr[i]. For that we …

Read more

Convert Sorted Array to Binary Search Tree Leetcode Solution

Consider we are given a sorted array of integers. The goal is to build a Binary Search Tree from this array such that the tree is height-balanced. Note that a tree is said to be height-balanced if the height difference of left and right subtrees of any node in the …

Read more

Multiply Strings Leetcode Solution

The problem Multiply Strings Leetcode solution asks us to multiply two strings which are given to us as input. We are required to print or return this result of multiplying to the caller function. So to put it more formally given two strings, find the product of the given strings. …

Read more

Sum of All Odd Length Subarrays Leetcode Solution

Problem Statement In this problem an array of positive integers is given. We have to calculate and return a single integer, the sum of all possible odd length subarrays of the given array. A subarray is a contiguous subsequence of the array. Example arr = [1,4,2,5,3] 58 Explanation: The odd-length subarrays of …

Read more

Translate »