Find Longest valid Parentheses Length [ Google ]

Problem: Given a string consisting of opening and closing parenthesis, find length of the longest valid parenthesis sub string.[Courtesy: geeksforgeeks] Problem Link Solution: The problem can be solved with DP approach . And also as counting the left and right parenthesis from left to right.If the left parenthesis count is less than the right parenthesis

Super Ugly Number – Extension of Ugly Number Problem

Problem: The problem is an extension of Ugly number problem. Problem Link : Here [Courtesy geeksforgeeks]


Maximum Boolean Parenthesization String [ Microsoft, Amazon]

Problem: Count the maximum number of ways we can parenthesize of a given boolean expression so that the value of expression evaluates to true or false as asked. Boolean expression will be given with following symbols. Symbols     ‘T’ —> true     ‘F’ —> false And the Operators     &   —> boolean AND     |   —>

Ugly Number Problem

Problem: The problem of ugly number is a common DP problem. Description: Ugly numbers are positive numbers whose prime factors only include 2,3,5,7. For example, 6,8 are ugly while 14 is not ugly since it includes another prime factor 7.Note that 1 is typically treated as an ugly number. courtesy:


Number that are not divisible [Paytm]

Problem: Find the number of non-divisible numbers in a range starting from 1 to N, for a given set. Problem Link [Courtesy:] Appeared as interview question in Paytm. Solution: The given set is {2,3,4,5,6,7,8,9,10}. The set can be minimized to {2,3,5,7} as these are the prime numbers and rest of the numbers of the

Find the longest palindrome of a String [Amazon,Microsoft]

Problem: Find the length and/or string of the longest palindrome of a string. The problem appeared as an Interview question in Amazon, Microsoft. Solution: One important property of a palindrome is if we remove the first and last characters of it , it would be another palindrome. So A string S[a..b] will be a palindrome

Find the Inversion Count of an Array [ Microsoft, Flipkart]

Problem: Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count is 0. If array is sorted in reverse order that inversion count is the maximum. Formally speaking, two elements a[i] and a[j] form an inversion if a[i] > a[j] and

Merge Sort


Find Minimum difference pair [ Amazon Interview Question]

Problem: Find the minimum difference between any pair in an unsorted  array.