https://github.com/skyv26/viral-advertising
HackerLand Enterprise is adopting a new viral advertising strategy. When they launch a new product, they advertise it to exactly 5 people on social media. On the first day, half of those 5 people (i.e., floor(5/2) = 2) like the advertisement and each shares it with of their friends. At the beginning of the second day, floor(5/2) x 3 = 2 x 3 = 6 people receive the advertisement. Each day, floor(recipients/2) of the recipients like the advertisement and will share it with 3 friends on the following day. Assuming nobody receives the advertisement twice, determine how many people have liked the ad by the end of a given day, beginning with launch day as day 1.A Hacker Rank Problem
https://github.com/skyv26/viral-advertising
Last synced: over 1 year ago
JSON representation
HackerLand Enterprise is adopting a new viral advertising strategy. When they launch a new product, they advertise it to exactly 5 people on social media. On the first day, half of those 5 people (i.e., floor(5/2) = 2) like the advertisement and each shares it with of their friends. At the beginning of the second day, floor(5/2) x 3 = 2 x 3 = 6 people receive the advertisement. Each day, floor(recipients/2) of the recipients like the advertisement and will share it with 3 friends on the following day. Assuming nobody receives the advertisement twice, determine how many people have liked the ad by the end of a given day, beginning with launch day as day 1.A Hacker Rank Problem
- Host: GitHub
- URL: https://github.com/skyv26/viral-advertising
- Owner: skyv26
- Created: 2022-09-23T06:45:43.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-23T06:57:52.000Z (almost 4 years ago)
- Last Synced: 2025-01-19T10:45:57.045Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Viral-Adverstising
A Hacker Rank Problem
HackerLand Enterprise is adopting a new viral advertising strategy. When they launch a new product, they advertise it to exactly 5 people on social media.
On the first day, half of those 5 people (i.e., floor(5/2) = 2) like the advertisement and each shares it with of their friends. At the beginning of the second day, floor(5/2) x 3 = 2 x 3 = 6 people receive the advertisement.
Each day, floor(recipients/2) of the recipients like the advertisement and will share it with 3 friends on the following day. Assuming nobody receives the advertisement twice, determine how many people have liked the ad by the end of a given day, beginning with launch day as day 1.
## Example
n = 5
Day Shared Liked Cumulative
1 5 2 2
2 6 3 5
3 9 4 9
4 12 6 15
5 18 9 24
The progression is shown above. The cumulative number of likes on the 5th day is 24.
## Function Description
Complete the viralAdvertising function in the editor below.
viralAdvertising has the following parameter(s):
- int n: the day number to report
### Returns
- int: the cumulative likes at that day
### Input Format
A single integer, n , the day number.
### Constraints
1 <= n <= 50
## Sample Input
3
## Sample Output
9
## Explanation

## Problem Link
[Click Here](https://www.hackerrank.com/challenges/strange-advertising/problem?isFullScreen=true)