#3850

Count Sequences to K

master · 1840 · lc hard +32 · 35.5% accepted · 81 likes · top 13%

Description

Given an integer array nums and an integer k, start with val = 1 and process elements left to right. At each index i you must pick exactly one action: multiply val by nums[i], divide val by nums[i] (exact rational division — e.g. 2 / 4 = 1/2), or leave val unchanged. Count the distinct choice sequences that yield val == k after all elements are processed.

Code

1
2
3