-
Notifications
You must be signed in to change notification settings - Fork 6
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
🌊 - Richelle #4
base: master
Are you sure you want to change the base?
🌊 - Richelle #4
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.
Nice work Richelle, you hit the learning goals, well done. Very clean code and well done.
Time Complexity: O(n) worst case if all are opening brackets | ||
Space Complexity: same as above | ||
*/ | ||
const balanced = (str) => { |
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.
👍 I love the use of the JS Object here as a hash.
Time Complexity: O(n) | ||
Space Complexity: O(n) | ||
*/ | ||
const evaluatePostfix = (expr) => { |
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.
👍
} | ||
|
||
enqueue(element) { | ||
throw new Error("This method has not been implemented!"); | ||
enqueue(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.
👍
this.store[this.tail] = value; | ||
this.tail = (this.tail + 1) % this.maxSize; | ||
} | ||
|
||
} | ||
|
||
dequeue() { |
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.
👍
// reset head and tail to -1 | ||
if (this.head === this.tail) this.head = this.tail = -1; | ||
|
||
return data; | ||
} | ||
|
||
front() { |
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 might also want to check to see if the queue is empty here.
} | ||
|
||
front() { | ||
throw new Error("This method has not been implemented!"); | ||
return this.store[this.head]; | ||
} | ||
|
||
size() { |
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.
👍
visited ++; | ||
} | ||
|
||
return count; | ||
} | ||
|
||
isEmpty() { |
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.
👍
No description provided.