Facebook Phone Interview
Company: Meta (Facebook)
Role: e3, e4
Interview Stage: Phone Screen
Location: unknown
Year: unknown
Original Post Content:
2 questions:
Q 1:
1. Daily public transportation pass costs $2.
7 days pass costs $6.
Monthly (30 days) public transportation pass costs $22.
given a sorted array[int] (31 > arr.length >= 0) where each cell contains a number which represent a day where a ride took place.
example:
arr = [1, 7, 23]
means that a ride took place on day 1, 7 and day 23.
Write a method that receives such an array as an input and returns a value which represents the minimum amount that can be payed for public transportation.
[1] => 2
[1, 2, 3] => 6
[1, 2, 3, 4] => 6
[1, 10, 11, 12, 30] => 10
Q2:
float calculateTaxes(income, brackets)
where "brackets" is a list of pairs, e.g.
[
[5000, 0],
[10000, 0.1],
[20000, 0.2],
[10000, 0.3],
[null, 0.4],
]
This indicates that:
The first $5K is untaxed
The next $10K is taxed at 10%
The next $20K is taxed at 20%
The next $10K is taxed at 30%
All income above this is taxed at 40%
So, for an income of $55K, the tax would be $0K + $1K + $4K + $3K + $4K = $12K.