Facebook Phone Interview

2 questions:
**Q 1: **

  1. Daily public transportation 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 10K is taxed at 10%
The next 10K is taxed at 30%
All income above this is taxed at 40%

So, for an income of 0K + 4K + 4K = $12K.

Comments (6)