Back to problems

Count Ordered Sequences That Sum to a Target

Algorithm · Optiver · Medium

Given a positive integer target and an array of distinct positive integers sizes, count the number of different ordered sequences that sum exactly to target. Each element of a sequence must be chosen from sizes, and any value may be reused as many times as needed. Ordering matters: sequences with the same elements arranged differently are counted separately. For example, [2, 3] and [3, 2] are distinct sequences. Implement count_order_sequences(target, sizes) -> int. Example…

Checking your access…