Any idea how to proceed with this,or any similar questions that I can find on leetcode!
Office Design
A company is repainting its office and would like to choose colors that work well together. They are presented with several various-priced color options presented in a specific order so that each color complements the surrounding colors. The company has a limited budget and would like to select the greatest number of consecutive colors that fit within this budget. Given the prices of the colors and the company's budget, what is the maximum number of colors that can be purchased for this repainting project?
Example
prices = [2,3,5, 1, 1, 2, 1]
money = 7
All subarrays that sum to less than or equal to 7:
Length 1 subarrays are [2],[3],[5],[1],[1], [2],[1 ]
Length 2 - [2,3], [5, 1], [1, 1], [1, 2], [2, 1]
Length 3 - [5. 1. 1],[1, 1, 2],[1,2,1]
Length 4 - [1, 1, 2, 1]
The longest of these, or the maximum number of colors that can be purchased, is 4.
Function Description
Complete the function getMaxColors in the editor below.
getMaxColors has the following parameters:
int prices[n]: the prices of the various paint colors
int money: the amount of money the company can spend on paints
Returns: int the maximum number of colors the company can purchase