-
Notifications
You must be signed in to change notification settings - Fork 44
Time - Alex #25
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
base: master
Are you sure you want to change the base?
Time - Alex #25
Conversation
CheezItMan
left a comment
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 Alex, you hit the learning goals here. Well done.
| # Time Complexity: O(n) | ||
| # Space Complexity: O(n) | ||
| def balanced(string) |
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.
👍
| } | ||
|
|
||
| string.each_char do |char| | ||
| if twosomes.values.include?(char) |
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.
Note about .include? is an O(n) operation and unnecessary in a hash.
| if twosomes.values.include?(char) | |
| if twosomes[char] |
| @back = -1 | ||
| end | ||
|
|
||
| def enqueue(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.
👍
| end | ||
| end | ||
|
|
||
| def 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.
👍
| def front | ||
| raise NotImplementedError, "Not yet implemented" | ||
| return @queue[@front] | ||
| end |
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 Queue is empty
| def get_queue_contents() | ||
| if @queue.empty? | ||
| return [] | ||
| elsif @front > @back | ||
| return @queue[@front...@size] + @queue[0...@back] | ||
| else | ||
| return @queue[@front...@back] | ||
| end | ||
| end |
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 like this one!
| @@ -1,22 +1,25 @@ | |||
| class Stack | |||
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.
👍
Stacks and Queues
Thanks for doing some brain yoga. You are now submitting this assignment!
Comprehension Questions
OPTIONAL JobSimulation