Last active
May 2, 2021 22:36
-
-
Save IEdiong/0c75d03221a1c712ff42e70d8700eeae to your computer and use it in GitHub Desktop.
Algorithm Fridays Week 4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prodOfNums(nums): | |
if len(nums) == 0: | |
return "invalid array: input an array of numbers" | |
else: | |
prod = 1 | |
ans = [] | |
for i in nums: | |
prod *= i | |
for i in range(0,len(nums)): | |
ans.append(prod // nums[i]) | |
return ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello @meekg33k, thank you for the feedback.
I did not consider this particular test case, but I must confess that my mind is being expanded as I participate in this challenge.
I did do some brainstorming for a better way that doesn't involve me creating a new
ans
array, but I couldn't come up with something good. Please I'm open to corrections and suggestions.