Documentation
¶
Index ¶
Constants ¶
const ( DIGITS ADD MINUS MULTIPLY DIVISE )
const ( DIGIT LETTER LEFT_BRACKET RIGHT_BRACKET UNKNOWN )
394. Decode String
Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times. Note that k is guaranteed to be a positive integer. You may assume that the input string is always valid; there are no extra white spaces, square brackets are well-formed, etc. Furthermore, you may assume that the original data does not contain any digits and that digits are only for those repeat numbers, k. For example, there will not be input like 3a or 2[4]. The test cases are generated so that the length of the output will never exceed 105.
Runtime: 3 ms, faster than 26.65% of Go online submissions for Decode String. Memory Usage: 2 MB, less than 91.85% of Go online submissions for Decode String.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MinStack ¶
type MinStack struct {
// contains filtered or unexported fields
}
155. Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. Implement the MinStack class: * MinStack() initializes the stack object. * void push(int val) pushes the element val onto the stack. * void pop() removes the element on the top of the stack. * int top() gets the top element of the stack. * int getMin() retrieves the minimum element in the stack. You must implement a solution with O(1) time complexity for each function.
Runtime: 33 ms, faster than 51.83% of Go online submissions for Min Stack. Memory Usage: 9 MB, less than 29.25% of Go online submissions for Min Stack.