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

Leaves - Sabrina #31

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

Conversation

Galaxylaughing
Copy link

No description provided.

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.

Overall nice work, you hit the learning goals here. Well done.

def super_digit(n)

puts "super_digit("+n.to_s+")"

Choose a reason for hiding this comment

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

I suggest leaving these out when you submit an answer.

Suggested change
puts "super_digit("+n.to_s+")"

else
sum = 0
while ((n / 10.0) > 0)
puts " while"

Choose a reason for hiding this comment

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

Suggested change
puts " while"

return new_solution
end

solutions = [last_solution, new_solution]

Choose a reason for hiding this comment

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

👍

# Time Complexity - O(n)
# because the while loop to create the concatenated number
# and the while loop adding the digits of the number are not nested.
# Space Complexity - O(log k * n)
def refined_super_digit(n, k)

Choose a reason for hiding this comment

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

This is the brute-force solution here. Can you think of a better way to do this with dynamic programming?

# Time Complexity - O(n)
# Space Complexity - O(n)
# you only keep the last two solutions, so the solutions array does not grow,
# but you're still effectiving the stack by adding recursive calls
# Hint, you may want a recursive helper method
def fibonacci(n)

Choose a reason for hiding this comment

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

👍

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