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

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

## 3Sum Leetcode Solution

Problem Statement Given an array of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. Notice: that the solution set must not contain duplicate triplets. Example #1 [-1,0,1,2,-1,4] …

## Maximum Number of Balloons Leetcode Solution

Problem Statement In this problem, we are given a string of characters containing lower-case English letters. We need to find how many instances of the word “balloon” can we make using the characters of the given string. Example String = “banooll” 1 Explanation: String = baqwweeeertylln 0 Explanation: As the …

## Search in Rotated Sorted Array Leetcode Solution

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 …

## Difference between highest and least frequencies in an array

The problem “Difference between highest and least frequencies in an array” states that suppose that you have an integer array. The problem statement asks to find out the maximum difference between the highest frequency and lowest frequency of two distinct numbers in an array. Example arr[] = {1, 2, 3, …

## Find whether a subarray is in form of a mountain or not

Problem Statement The problem “Find whether a subarray is in form of a mountain or not” states that you are given an integer array and a range. The problem statement asks to find out whether the sub-array formed between the given range is in form of a mountain form or …

## Rearrange a binary string as alternate x and y occurrences

Problem Statement Suppose you are given a binary string, and two numbers x and y. The string consists of 0s and 1s only. The problem “Rearrange a binary string as alternate x and y occurrences” asks to rearrange the string such that the 0 comes x times ⇒ 1 comes …

## Count subarrays with equal number of 1’s and 0’s

Problem Statement The problem “Count subarrays with equal number of 1’s and 0’s” states that you are given an array consisting of 0’s and 1’s only. The problem statement asks to find out the count of sub-arrays consisting equal no of 0’s ad 1’s. Example arr[] = {0, 0, 1, …

## Rearrange array such that even index elements are smaller and odd index elements are greater

Problem Statement You have given an array of integers. The problem “Rearrange array such that even index elements are smaller and odd index elements are greater” asks to rearrange the array in such a manner that the even index elements should be smaller than the odd index elements in a …