Ad
  • Custom User Avatar

    The items are prioritized by value per size, not by size alone.

    If you divide value by size for those 5 items, you get:

    item[0]: 7.4 / 11.2 = 0.6607142857142858
    item[1]: 17.8 / 25.6 = 0.6953125
    item[2]: 41.2 / 51.0 = 0.807843137254902
    item[3]: 15.6 / 23.9 = 0.6527196652719666
    item[4]: 19.0 / 27.8 = 0.6834532374100719

    So the item with highest value/size is item[2], (51.0, 41.2). You take 1 of them. The remaining capacity is 49.
    The next highest value/size is item[1], (25.6, 17.8). You take 1 of them. The remaining capacity is 23.4.
    The 3rd highest value/size is item[4], (27.8, 19.0). You don't have enough room to take any of them.
    The 4th highest value/size is item[0], (11.2, 7.4). You have room for 2 of them. The remaining capacity is 1.
    The least value/size is item[3], (23.9, 15.6). You don't have room to take any.
    The result is [2, 1, 1, 0, 0].

  • Custom User Avatar

    Excellent point. :)

  • Custom User Avatar

    A hint: Count groups of 0s as well as groups of 1s in order to determine the time unit.

  • Custom User Avatar

    111 could only be either a single dot or a single dash, it can't be 3 dots like in "S", as that would require some 0's between 1's.

  • Custom User Avatar

    actually the parameters in assertArrayEquals are (expected,actual) in the test cases.