Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chan - rock #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

chan - rock #2

wants to merge 2 commits into from

Conversation

chanbzz
Copy link

@chanbzz chanbzz commented Nov 1, 2021

time-boxed and didn't finish problems.js. will complete if i get through cs fun

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.

Chan, it's clear you didn't finish, but thanks for submitting what you had. The biggest thing is that you didn't write the queue as a circular buffer and so end up with an O(n) dequeue operation.

Comment on lines +13 to +16
if (string[index] in bracketMap) {
stack.push(string[index]);
}
// compare bracket to hash value

Choose a reason for hiding this comment

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

for this one you'd need to check to see if the character is a key in the object. If so, pop and compare to make sure they match, if not then you can push the current character onto the stack.

Comment on lines +9 to +14
if (this.rear === (this.size() - 1)) {
throw new Error ('queue full');
} else {
this.rear++;
}
this.store[this.rear] = element;

Choose a reason for hiding this comment

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

This isn't working as a circular buffer.

Comment on lines +18 to +27
if (this.front === (this.size() - 1)) {
throw new Error ('queue full');
} else {
this.front++;
}

const fifo = this.store[this.front];
this.store[this.front] = null;

return fifo;

Choose a reason for hiding this comment

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

ditto to the above

}

pop() {
throw new Error("This method has not been implemented!");
let removedItem = this.store.getLast();
this.store.delete(removedItem);

Choose a reason for hiding this comment

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

you could simply use removeLast

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