Python | Multiplication till Null value
The prefix array is quite famous in the programming world. This article would discuss a variation of this scheme. This deals with the cumulative list product till a False value, and again starts cumulation of product from occurrence of True value. Let’s discuss certain way in which this can be performed.
Method #1 : Using Naive Method
In the naive method, we just construct the new list comprising of the the product of prev. value of list until False and restarts the procedure once a True value is encountered.
The original list is : [1, 3, 4, False, 4, 5, False, 7, 8] The computed modified new list : [1, 3, 12, 1, 4, 20, 1, 7, 56]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course