Conversation
CheezItMan
left a comment
There was a problem hiding this comment.
Overall nice work Ida. You have working methods here, but there are some issues here with time/space complexity. Take a look at my comments and let me know what questions you have.
| @@ -0,0 +1,6 @@ | |||
| # Default ignored files | |||
There was a problem hiding this comment.
I suggest you add .idea to your .gitignore or .gitignore_global files.
| # Time complexity: O(n) | ||
| # Space complexity: O(n) | ||
| def factorial(n) |
| # Time complexity: O(n) | ||
| # Space complexity: O(n) | ||
| def reverse(s) |
There was a problem hiding this comment.
👍 , however this is O(n^2) because you are doing the same as the slice method with each recursive call.
| # Time complexity: O(n) | ||
| # Space complexity: 0(n) | ||
| def reverse_inplace(s) |
There was a problem hiding this comment.
This works, but it is not in place and essentially the same as the previous method.
Think about if you adjusted the method signature as follows
| # Time complexity: O(n) | |
| # Space complexity: 0(n) | |
| def reverse_inplace(s) | |
| # Time complexity: O(n) | |
| # Space complexity: 0(n) | |
| def reverse_inplace(s, low = 0, high = s.length - 1) |
| # Time complexity: o(n) | ||
| # Space complexity: o(n) | ||
| def bunny(n) |
| # Time complexity: o(n) | ||
| # Space complexity: o(n) | ||
| def nested(s) |
There was a problem hiding this comment.
👍 However because you have a slice with each recursive call, this is O(n^2) for both time and space complexity.
| # Time complexity: o(n) | ||
| # Space complexity: o(n) | ||
| def search(array, value) |
There was a problem hiding this comment.
👍 However due to the slice you have O(n^2) for time and space complexity.
| # Time complexity: o(n) | ||
| # Space complexity: o(n) | ||
| def is_palindrome(s) |
There was a problem hiding this comment.
👍 Similar issues to the above with time and space complexity.
| # Time complexity: o(n) | ||
| # Space complexity: o(n) | ||
| def digit_match(n, m) |
There was a problem hiding this comment.
👍 Similar issues on time/space complexity.
No description provided.