Range Sum Query 2D – Immutable Leetcode Solution

Problem Statement Range Sum Query 2D – Immutable Leetcode Solution – Given a 2D matrix matrix, handle multiple queries of the following type: Calculate the sum of the elements of matrix inside the rectangle defined by its upper left corner (row1, col1) and lower right corner (row2, col2). Implement the NumMatrix class: NumMatrix(int[][] matrix) Initializes the object with the integer …

Read more

Meeting Rooms II LeetCode Solution

Problem Statement The Meeting Rooms II LeetCode Solution – “Meeting Rooms II” states that you are given an array of meeting time intervals “intervals” where “intervals[i] = [ start[i], end[i] ]”, return the minimum number of conference rooms required. Example: intervals = [[0,30],[5,10],[15,20]] 2 Explanation: Meeting one can be done …

Read more

Subarray Sum Equals K LeetCode Solution

Problem Statement The Subarray Sum Equals K LeetCode Solution – “Subarray Sum Equals K” states that you are given an array of integers “nums” and an integer ‘k’, return the total number of continuous subarrays whose sum equals to ‘k’. Example: nums = [1, 2, 3], k=3 2 Explanation: There …

Read more

Longest Palindromic Substring LeetCode Solution

Problem Statement The Longest Palindromic Substring LeetCode Solution – “Longest Palindromic Substring” states that You are Given a string s, return the longest palindromic substring in s. Note: A palindrome is a word that reads the same backward as forwards, e.g. madam. Example:   s = “babad” “bab” Explanation: All …

Read more

Best Time to Buy and Sell Stock LeetCode Solution

Problem Statement The Best Time to Buy and Sell Stock LeetCode Solution – “Best Time to Buy and Sell Stock” states that You are given an array of prices where prices[i] is the price of a given stock on an ith day. You want to maximize your profit by choosing …

Read more

Median of Two Sorted Arrays LeetCode Solution

Problem statement Median of Two Sorted Arrays LeetCode solution – In the problem “Median of Two Sorted Arrays”, we are given two sorted arrays nums1 and nums2 of size m and n respectively, and we have to return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example nums1 = [1,3], …

Read more

Number of Islands LeetCode Solution

Problem Statement The number of Islands LeetCode Solution – “Number of Islands” states that you are given an m x n 2D binary grid which represents a map of ‘1’s (land) and ‘0’s (water), you have to return the number of islands. An island is surrounded by water and is …

Read more

Check If Two String Arrays are Equivalent Leetcode Solution

The problem Check If Two String Arrays are Equivalent Leetcode Solution provides us two arrays of strings. Then we are told to check if these two string arrays are equivalent. The equivalence here refers to the fact that if the strings in the arrays are concatenated. Then after concatenation, both …

Read more

Check Array Formation Through Concatenation Leetcode Solution

The problem Check Array Formation Through Concatenation Leetcode Solution provided us with an array of arrays. Along with that we are also given a sequence. We are then told to find if we can somehow construct the given sequence using array of arrays. We can arrange the arrays in any …

Read more

Translate »