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

0% completed

Vote For New Content
In Subarrays with Product Less than a Target, I don't understand why you use a D...

agustin.vaca

Apr 28, 2022

In Subarrays with Product Less than a Target, I don't understand why you use a Deque in the Python solution. It seems like you're only appending items left to preserve an order, is this important?

0

0

Comments
Comments
Design Gurus
Design Gurus3 years ago

You can use any data structure that allows inserting elements at the beginning.

B
bleech94 3 years ago

It looks like we are creating a deque, looping backwards, and appending to the front of the deque. Instead could we just reverse the loop, remove the deque and append a subset of the array to the result? Using something like result.append(arr[left:right]) and incrementi...

On this page