First Fibonacci Number at Least the Array Sum
Updated
Problem statement
Given a nonempty array of nonnegative integers values, compute its sum S. Return the first Fibonacci number that is greater than or equal to S.
The sequence is defined by F0 = 0, F1 = 1, and Fk = F(k - 1) + F(k - 2) for k >= 2. “First” means the earliest value in this sequence, so a sum of 0 returns 0.
Function
firstFibonacciAtLeastSum(values: int[]) → longExamples
Example 1
values = [4,1,3]return = 8The sum is 8, which is itself a Fibonacci number.
Example 2
values = [2,2]return = 5The sum is 4. The first Fibonacci number at least 4 is 5.
Constraints
1 <= values.length <= 100000.0 <= values[i] <= 1000000000.- The sum of all values is at most
100000000000000.
More BitGo Online Assessment questions
Similar questions at other companies
- Basic Item DiscountsPalantir · OAPalantir interview questions
- Diagonal Bounce TraversalAutodesk · OAAutodesk interview questions
- Costliest ChocolateRippling · OARippling interview questions
- Online No-Intercept Linear RegressionTwo Sigma · OATwo Sigma interview questions
- Plus Mult ArrayIBM · OAIBM interview questions
- Progressive Tax CalculatorInteractive Brokers · OA
- 2020 Account Balance with Monthly Card FeesDRW · OADRW interview questions
- Array Challenge (QR Intern)Akuna Capital · OAAkuna Capital interview questions
- Latency Bucket CounterDatadog · OA · PHONE SCREENDatadog interview questions
- Metro Fare With a Daily CapMicrosoft · OAMicrosoft interview questions