LeetCode 22. Generate Parentheses Java Solution And Time Complexity Explanation

Generating all possible combinations of balanced parentheses is a common interview problem & is found in websites like LeetCode & GeeksForGeeks.Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. We are using backtracking to solve this problem. There are two cases where we can proceed to the next recursive … Read more

Java Program To Solve Word Break Problem

Given a string A and a dictionary of words B, find out if A can be segmented into a space-separated sequence of dictionary words. Input: A = “myinterviewtrainer”, B = [“trainer”, “my”, “interview”]Output: 1 (“myinterviewtrainer” can be segmented as “my interview trainer”) Input: A = “cc” B = [“ccc”]Output: 0 (“cc” can’t be segmented as … Read more

Java Program For Shortest Unique Prefix Problem

Shortest Unique Prefix is an interview question which you can find in websites like GeeksForGeeks & InterviewBit. It is asked in Google interviews. Basically we need to find shortest unique prefix to represent each word in the list. Input: [zebra, dog, duck, dove]Unique Prefix of each word is as below:zebra = zdog = dogduck = … Read more

Better Explanation Of Order of People Heights Problem And Java Program To Solve It

Order of People Heights is an interview question that is asked in Google. You can find the question in websites like InterviewBit & CareerCup. But the problem is that you won’t find a good explanation of the problem anywhere. Let me try to describe the problem statement clearly. Input : Heights: 5 3 2 6 … Read more