Skip to content

Branches - Diana#47

Open
dhan0406 wants to merge 2 commits intoAda-C12:masterfrom
dhan0406:master
Open

Branches - Diana#47
dhan0406 wants to merge 2 commits intoAda-C12:masterfrom
dhan0406:master

Conversation

@dhan0406
Copy link

Sorry, it's late! Passing MOST of the tests except for nested & digit match

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.

Nice work, I'm glad you got it in. some small issues here, but overall not bad.

require 'pry'
# Time complexity: O(n)
# Space complexity: O(n)
def factorial(n)

Choose a reason for hiding this comment

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

👍

# Time complexity: O(n)
# Space complexity: O(n)
# I think this is reversing the string in place?
def reverse(s)

Choose a reason for hiding this comment

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

👍

def reverse_inplace(s)
raise NotImplementedError, "Method not implemented"
return s if s.length <= 1
return reverse_inplace(s[1..-1]) + s[0]

Choose a reason for hiding this comment

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

This creates a new array, so it's not in place

# Space complexity: ?
# Time complexity: O(n)
# Space complexity: O(n)
def bunny(n)

Choose a reason for hiding this comment

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

👍

# Time complexity: ?
# Space complexity: ?
# NOT PASSING TESTS
def nested(s)

Choose a reason for hiding this comment

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

Ok so not implemented

raise NotImplementedError, "Method not implemented"
# Time complexity: O(n)
# Space complexity: O(n)
def search(array, value, i = 0)

Choose a reason for hiding this comment

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

👍

return false
end

while l < s.length

Choose a reason for hiding this comment

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

You don't need a while if it's recursive.

You can make the base case

return true if i >= r

tracker += 0
end

return tracker if i < -(n.length)

Choose a reason for hiding this comment

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

If i is less than n's length?

def digit_match(n, m)
raise NotImplementedError, "Method not implemented"
# NOT PASSING TESTS
def digit_match(n, m, i = -1)

Choose a reason for hiding this comment

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

You can also pull off digits by % 10.

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