You are viewing a single comment's thread. Return to all comments →
easy approach
public static int viralAdvertising(int n) { if (n <= 0) return -1; int likes = 0; int peopleShare = 5; for (int i = 1; i <= n; i++) { int peopleLike = (int) Math.floor(peopleShare / 2); // 2 likes += peopleLike; peopleShare = peopleLike * 3; } return likes; }
Seems like cookies are disabled on this browser, please enable them to open this website
Viral Advertising
You are viewing a single comment's thread. Return to all comments →
easy approach