about | help | code help+videos | done | prefs |
Write a method that returns how much room remains in the last bin that is used. Bins are used in the order of their numbers. The parameter 'total' contains the total number of items to be placed. Begin placing items into bin1. If all of the items can be placed in bin1, return the amount of space remaining in bin1 (possibly 0). However, if not all of the items in 'total' fit in bin1, first fill bin1, then continue placing items in bin2. Continue in this process until all items from 'total' are placed in as many bins as needed. Return the amount of space remaining in the last bin that needs to be used. However, if the 'total' of items needed to be placed is greater than the total space available in ALL of the bins combined, return -1 as an error code. jan8_2016_APSLHLpidgenhole(456, 30, 50, 400) → 56 jan8_2016_APSLHLpidgenhole(456, 30, 50, 460) → 26 jan8_2016_APSLHLpidgenhole(5, 5, 5, 15) → 0 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 230
Copyright Nick Parlante 2017 - privacy