Java

Server-less Java : CanSum

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]?

Solve

Step 1. The Method


Using memoisation as a cache of already calculated values decreases the time complexity from the exponential O(2n) down to a mere linear O(n) !!

Implement

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