From InterviewBit Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses of length 2*n.For example, given n = 3, a solution set is:”((()))”, “(()())”, “(())()”, “()(())”, “()()()” Make sure the returned list of strings are sorted. Solution / Approach Basically, for each character you can insert “(” or “)”. You needLanjutkan membaca “Parentheses Generator”
Arsip Bulanan:Agustus 2019
Combination Sum
From InterviewBit; Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited number of times.
MinStack
Problem Design a stack that have a constant time to fetch the minimum element in the stack. Solution Approach: Maintain a queue that store list of minimum element However, since our data structure is a stack, it will come with a caveat: first in, last out This means that if we find a minimum element,Lanjutkan membaca “MinStack”