Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Vote For New Content
Eric Imho Jang
My python solution

Eric Imho Jang

Jul 26, 2024

class Solution: def findSubarrays(self, arr, target): result = [] for i in range(len(arr)): left = i right = i product = 1 while product < target: print(left, right, result) if left == right and arr[left] < target: result.append([arr[left]]) right += 1 elif left < right and right < len(arr): start = left end = right+1 product = 1 for i in range(start, end): product *= arr[i] if product < target: result.append(arr[start:end]) right += 1 else: break else: break return result

0

0

Comments
Comments