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 …

Read moreSearch in Rotated Sorted Array Leetcode Solution

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

Read moreDifference between highest and least frequencies in an array

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 …

Read moreFind whether a subarray is in form of a mountain or not

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 …

Read moreRearrange a binary string as alternate x and y occurrences

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

Read moreCount subarrays with equal number of 1’s and 0’s

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 …

Read moreRearrange array such that even index elements are smaller and odd index elements are greater

Count pairs from two linked lists whose sum is equal to a given value

Problem Statement Problem “Count pairs from two linked lists whose sum is equal to a given value” state that you are given two linked lists and an integer value sum. The problem statement asked to find out how many total pair has a sum equal to the given value. Example …

Read moreCount pairs from two linked lists whose sum is equal to a given value

Count items common to both the lists but with different prices

Problem Statement You are given two lists. Each of which index contains the name of the item and its price. The problem statement asks to count items common to both the lists but with different prices, which is to find out how many numbers of items are common in both …

Read moreCount items common to both the lists but with different prices