Search
⌘K

Leetcode 2929. Distribute Candies Among Children II

Count the number of nonnegative integer triples (a,b,c) with a + b + c = n and 0 ≤ a,b,c ≤ limit. With n, limit up to 1e6, the task is to compute this count efficiently using combinatorics (stars-and-bars with inclusion–exclusion) rather than brute force.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.