Tagged Questions
4
votes
2answers
48 views
Stock span problem
The stock span problem is a financial problem where we have a series of n daily price quotes for a stock and we need to calculate span of stock’s price for all n days.
The span Si of the stock’s ...
6
votes
4answers
139 views
Stack with 'getMinimum' operation
Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should return minimum element from the ...
4
votes
1answer
46 views
Stack with “getMiddle” and “deleteMiddle” operation
Looking for code review, optimizations and best practices.
...
4
votes
1answer
34 views
Implement stack using a linked list
I am trying to implement Stack using a linked list. Looking for code-review, best practices and optimizations.
...
7
votes
1answer
44 views
Find the Next Greatest Element
Given an array, print the Next Greater Element (NGE) for every element. The Next Greater Element for an element x is the first greater element on the right side of x in array. Elements for which no ...
3
votes
2answers
48 views
Class that implements a queue using two stacks
I am looking for a review of my code that implements a MyQueue class which implements a queue using two stacks.
...
3
votes
2answers
143 views
How is my Java code for stack implementation?
The following example shows how to implement stack by creating user defined push() method for entering elements and pop() method ...
12
votes
6answers
2k views
Implementing a Stack in Java for Technical Interview
This code is based off the Stack implementation in Chapter 3 of Cracking The Coding Interview. I modified the code to make it compile and give me the correct output. I'd appreciate any feedback on ...
0
votes
2answers
89 views
Stack implementation using a queue
I've implemented a stack using a queue.
Time complexity:
\$O(n)\$ - push(), where n is the number of elements in the queue
\$O(1)\$ - ...
3
votes
1answer
50 views
Infix to postix conversion
I'm looking for code review, optimizations and best practices.
Also verifying complexity to be O(n), where n is the string length.
...
12
votes
7answers
1k views
Check for balanced parentheses
Given an expression string exp, write a program to examine whether the
pairs and the orders of
"{","}","(",")","[","]"
are correct in exp.
For ...
-1
votes
2answers
2k views
1
vote
1answer
2k views
Postfix evaluation using a stack
I just wrote the code to evaluate a postfix expression and would like it if someone reviews it for me, it works perfectly fine but I'm having trouble adding the character "=" at the end.
...
5
votes
1answer
183 views
How is my implementation of an immutable stack?
Below is my implementation of an immutable stack class. The reverse function is trying to return a stack with all elements reversed. Is my implementation good? Maybe the reverse function can be ...
5
votes
3answers
2k views
A simple array-based Stack class in Java, what are my mistakes?
I have created a simple array-based Stack class with some methods like the actual Stack in Java.
I am testing this for mistakes, but since I am learning Java and my tests may not be as comprehensive ...
5
votes
2answers
621 views
Java and stacks: correct implementation?
I created this very simple stack concept's implementation.
Could you tell me if it is correct and clean? Do you see any bad coding habits?
...
3
votes
3answers
464 views
General purpose object array [closed]
I'm still new to Java and I'm trying to create a general purpose stack queue that uses an object array. I known that I've done things incorrectly, namely declaring the arrays and assigning the array ...