= count of valid completions. Base case: returns . Memoize only when . When tight, the valid digit range depends on the specific limit, breaking reuse. Alternative: memoize all states with limit baked in. Use where tight is binary. Trade space for simplicity. Time: where is digit count. Space: with memoization.
Time complexity: .
Space complexity: .