-
Notifications
You must be signed in to change notification settings - Fork 4
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
Aimee 👾 - Fire 🔥 #4
base: master
Are you sure you want to change the base?
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.
Well done Aimee, you hit the essential classes. Nice work.
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) => { |
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'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) { |
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.
👍
throw new Error("Queue is Full!") | ||
} | ||
this.store[len] = value; | ||
this.tail = (this.tail + 1) % Queue.maxLenth; | ||
} | ||
|
||
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.
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) { |
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.
👍
push() { | ||
throw new Error("This method has not been implemented!"); | ||
push(value) { | ||
this.store.addLast(value); | ||
} | ||
|
||
pop() { |
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.
👍
throw new Error("This method has not been implemented!"); | ||
const lastValue = this.store.getLast() | ||
this.store.delete(lastValue); | ||
return lastValue; | ||
} | ||
|
||
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.