-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: master
Are you sure you want to change the base?
chan - rock #2
Conversation
There was a problem hiding this 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.
if (string[index] in bracketMap) { | ||
stack.push(string[index]); | ||
} | ||
// compare bracket to hash value |
There was a problem hiding this comment.
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.
if (this.rear === (this.size() - 1)) { | ||
throw new Error ('queue full'); | ||
} else { | ||
this.rear++; | ||
} | ||
this.store[this.rear] = element; |
There was a problem hiding this comment.
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.
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; |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
time-boxed and didn't finish problems.js. will complete if i get through cs fun