Skip to content

Conversation

@marks214
Copy link

@marks214 marks214 commented Apr 5, 2021

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done Aimee, you hit the essential classes. Nice work.

Comment on lines +3 to 6
Time Complexity: O(n^2) - the stack.pop() method invoked has O(n) time complexity and it is used inside a for loop.
Space Complexity: O(n) - we keep pushing values to the stack for a string of length n.
*/
const balanced = (str) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I'm pretty sure the pop method has O(1) time complexity leading your solution to O(n) time complexity overall.


enqueue(element) {
throw new Error("This method has not been implemented!");
enqueue(value) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

this.tail = (this.tail + 1) % Queue.maxLenth;
}

dequeue() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should also check to see if the head and tail are equal, if so the Queue is empty and you should do something to avoid removing null entries.


push() {
throw new Error("This method has not been implemented!");
push(value) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

this.store.addLast(value);
}

pop() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return lastValue;
}

isEmpty() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants