Given two non-negative integers N and K, return the number of binary strings of length N with exactly K ones
Example:
Input: N = 4, K = 2
Output: 6
Explanation: [
"1100",
"1010",
"1001",
"0110",
"0101",
"0011"
]
Notes:
K <= N <= 30
Walkthroughs of the solution. Try the steps first, then watch to compare approaches.
Free plan: 30 tutor messages. Premium is unlimited.
Saved
Ctrl + Enter to check