Start learning free

LESSON 321 OF 349 · DYNAMIC PROGRAMMING

Binary Strings With K Ones On Even Positions in Swift

Practice O(n * k)

Given two non-negative integers N and K, return the number of binary strings of length N with exactly K ones placed only on even positions

Example:

Input: N = 6, K = 2
Output: 3
Explanation: [
    "101000",
    "100010",
    "001010"
]
Notes: 2 * K <= N <= 30
STEP 1 OF 8
    Ctrl + Enter to check

    Binary Strings With K Ones On Even Positions in Swift

    Keep going with SwiftAbout 340 step-by-step lessons, from your first line of code to coding interviews. Free to start.
    Start learning free