Tap here to switch tabs
Problem
Submissions

Problem: Direction Assignments with Exactly K Visible People

Try to solve the Direction Assignments with Exactly K Visible People problem.

Statement

You are given three integers n, pos, and k.

There are n people standing in a line, indexed from 00 to n −1- 1. Each person independently chooses to face either left, denoted by 'L', or right, denoted by 'R'.

A person at index i is visible to the observer at index pos if:

  • i << pos and the person at i faces left ('L').

  • i >> pos and the person at i faces right ('R').

The direction chosen by the person at index pos does not affect the count of visible people.

Return the total number of valid direction assignments for all n people such that exactly k people are visible to the observer at index pos.

Constraints:

  • 1≤1 \le n ≤105\le 10^5

  • 0≤0 \le pos, k ≤\le n −1- 1

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Direction Assignments with Exactly K Visible People

Try to solve the Direction Assignments with Exactly K Visible People problem.

Statement

You are given three integers n, pos, and k.

There are n people standing in a line, indexed from 00 to n −1- 1. Each person independently chooses to face either left, denoted by 'L', or right, denoted by 'R'.

A person at index i is visible to the observer at index pos if:

  • i << pos and the person at i faces left ('L').

  • i >> pos and the person at i faces right ('R').

The direction chosen by the person at index pos does not affect the count of visible people.

Return the total number of valid direction assignments for all n people such that exactly k people are visible to the observer at index pos.

Constraints:

  • 1≤1 \le n ≤105\le 10^5

  • 0≤0 \le pos, k ≤\le n −1- 1