diff --git a/NeetCodeRoadmap/Arrays_and_Hashing/238_Product_of_Array_Except_Self.py b/NeetCodeRoadmap/Arrays_and_Hashing/238_Product_of_Array_Except_Self.py index dcf5b68..68a18d7 100644 --- a/NeetCodeRoadmap/Arrays_and_Hashing/238_Product_of_Array_Except_Self.py +++ b/NeetCodeRoadmap/Arrays_and_Hashing/238_Product_of_Array_Except_Self.py @@ -1,6 +1,15 @@ -def productExceptSelf(self, nums): +def productExceptSelf(nums): """ :type nums: List[int] :rtype: List[int] """ - \ No newline at end of file + numsProduct = [] + for x in range(len(nums)): + firstHalf = nums[:x] + secondHalf = nums[(len(nums)-x):] + if firstHalf: + product = firstHalf + secondHalf + numsProduct.append(product) + return numsProduct + +print(productExceptSelf([1,2,3,4])) \ No newline at end of file