Sum of Left Leaves Leetcode Solutions
In this problem, we have to find the sum of all left leaves in a binary tree. A leaf that is called a “Left Leaf” if it is a left child of any node in the tree. Example 2 / \ 4 7 / \ 9 4 Sum is 13 …
In this problem, we have to find the sum of all left leaves in a binary tree. A leaf that is called a “Left Leaf” if it is a left child of any node in the tree. Example 2 / \ 4 7 / \ 9 4 Sum is 13 …
The problem Permutations Leetcode Solution provides a simple sequence of integers and asks us to return a complete vector or array of all the permutations of the given sequence. So, before going into solving the problem. We should be familiar with permutations. So, a permutation is nothing but an arrangement …
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 …
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 …
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 …
In the problem “Merge Sorted Arrays”, we are given two arrays sorted in non-descending order. The first array is not fully filled and has enough space to accommodate all elements of the second array as well. We have to merge the two arrays, such that the first array contains elements …
Consider a sorted array but one index was picked and the array was rotated at that point. Now, once the array has been rotated you are required to find a particular target element and return its index. In case, the element is not present, return -1. The problem is generally …
In this problem, we are given an integer and are required to convert into roman numeral. Thus the problem is generally referred to as “Integer to Roman” and this is Integer to Roman Leetcode Solution. If someone does not know about Roman numerals. In the old times, people did not …
In this problem, we are given a sorted array and a target integer. We have to find its Search Insert Position. If the target value is present in the array, return its index. Return the index at which the target should be inserted so as to keep the order sorted(in …
Problem Statement In running sum of 1d array problem we have been given an array nums for which we have to return an array where for each index i in the result array arr[i] = sum( nums[0] … nums[i] ). Example nums = [1,2,3,4] [1,3,6,10] Explanation: Running sum is : …