Zepruv › Coding problems

Find the Minimum Number of Fibonacci Numbers Whose Sum Is K

Medium · Math, Greedy

Given an integer k, return the minimum number of Fibonacci numbers whose sum is equal to k. The same Fibonacci number can be used multiple times.
The Fibonacci numbers are defined as:

Example 1

Input: k = 7
Output: 2

The Fibonacci numbers are: 1, 1, 2, 3, 5, 8, 13, ... For k = 7 we can use 2 + 5 = 7.

Example 2

Input: k = 10
Output: 2

For k = 10 we can use 2 + 8 = 10.

Example 3

Input: k = 19
Output: 3

For k = 19 we can use 1 + 5 + 13 = 19.

Constraints

Starter code (python)

class Solution(object):
    def findMinFibonacciNumbers(self, k):
        """
        :type k: int
        :rtype: int
        """
        

Related problems

Previous: Minimum Value to Get Positive Step by Step Sum · Next: Restore The Array · All problems

Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.