Java

Server-less Java : HowSum

Java as cloud-deployed AWS Lambda Functions operating through the AWS API Gateway.


Simple, interactive Java examples collected over the last 10 months or so...

Problem

Given a target number t, is it possible to make t as a combination sum from a list of numbers [x1..xn], and if so, what is the BEST combination {the one with fewest numbers needed}?

Solve

Step 1. The Method


Again, using memoisation here to keep a record of already calculated combinations. This means the time complexity is reduced and also that the shortest {best} combination can be easily tracked too!

Implement

The list of numbers from which to make the target sum, eg. 2, 4, 7 (use comma separators)