We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Viral Advertising
Viral Advertising
Sort by
recency
|
1342 Discussions
|
Please Login in order to post a comment
Here is my c++ solution, you can watch the explanation here : https://youtu.be/SbHCdf_c7ss
Python3 Simple Brute force approach.
Solution with recursion
def viralAdvertising(n): def rec(n, r): if n == 1: return r return r + rec(n-1, r*3//2)
I spent a lot of time trying to figure out an o(1) solution.
It looks like a form of exponential or logarithmic growth that can be calculated without iterating through an array. Anyone have any ideas?