Tag: Google interview questions
-
155. Min Stack
155. Min Stack Solution programming interview question. Design a stack that can return the minimum element in constant time and also support pus, pop and top methods. Example:Input[“MinStack”,”push: -3″,”push: 0″,”push: -5″,”getMin”,”pop”,”top”,”getMin”] OutputMinStack minStack = new MinStack();minStack.push(-3); // returns nullminStack.push(0); // returns nullminStack.push(-5); // returns nullminStack.getMin(); // return -5minStack.pop(); // returns nullminStack.top(); // return 0minStack.getMin(); //…
-
20. Valid Parentheses Leetcode Solution
Valid Parentheses Leetcode 20 Solution Return boolean indicating wether the pairs of paranthesis are matching and there are no un-matched paranthesis found. Using a list to implement a stack in Python.Store all the pairs of opening and closing tags in a dictionary. Closing brackets are the key.Go thru the characters of the string and add…