Atlassian | Portfolios

Difficulty: EASYCategory: InterviewExperienceFrequency: 1Asked On 2019-10-12Added By Anonymous
Source: Link

This is the question asked in phone interview of atlassian


Input to the function will be amount and portfolio object. return an object with the amount being equally distributed based on the portfolio given.

•stocks: AAPL, EA, ATVI, OKTA, TEAM
•portfolios: p1, ..., p4


portfolios are defined as

1 * p1: 0.4 p2, 0.2 AAPL, 0.4 EA 2 * p2: 0.4 p3, 0.4 p4, 0.2 AAPL 3 * p3: 0.2 EA, 0.8 ATVI 4 * p4: 0.6 OKTA, 0.4 TEAM``` 5 * 6Portfolio can be nested : ```p1: 0.4 p2, 0.2 AAPL, 0.4 EA ``` 7 8Given the amount 1000$ and portfolio p4 as the input return as below 9```/** 10 * e.g. Input given is p4, $1000 -> {"OKTA": $600, "TEAM": $400, ......} 11 * p1 -> ?? 12 * p2 -> ?? 13 * p3 -> ?? 14 */``` 15 16 Any inputs on how to solve this??. I strugled a lot in forming the portfolio object. I was so confused. 17 Need some input from you. 18 19 Thanks.


Comments