The TransCompilator

Solved LeetCode program · 366 of 1,000

#0494 · Target Sum

Medium Array chunk-08.md

Original English source

Keep a shared numbers holding 1, 1, 1, 1, and 1. Keep a shared ways of 0. Keep a shared aim of 3.
To score with total (a whole number). If total is aim, add 1 to ways.

To branch from spot (a whole number) with total (a whole number). If spot is at least 5, score with total, return. The amount is item spot of numbers. Branch from spot plus 1 with total plus amount. Branch from spot plus 1 with total minus amount.

Branch from 0 with 0. Show ways.

Open in Playground Browse all 1,000 problems

Expected stdout

5