#247How many positions can each query see?Easy

How many positions can each query see?

Background

Under causal masking, query position i may attend to keys 0, 1, …, i — itself and everything before, never the future. So the number of visible positions per row is:

visible(i)=i+1\text{visible}(i) = i + 1

These are exactly the row-sums of a T × T lower-triangular ones matrix: [1, 2, 3, …, T].

Problem statement

Implement visible_counts(T) returning the list of visible-position counts per query.

Input

  • Tint, sequence length.

Output

Returns a list of int: [1, 2, 3, …, T] (count for positions 0..T-1).

Examples

Example 1

Input:  T = 4
Output: [1, 2, 3, 4]

Constraints

  • Position i sees i + 1 positions.
  • Return a length-T list.

Notes

  • The last position sees the whole sequence; the first sees only itself. That triangular structure is what makes generation autoregressive.
Python
Loading...

▶ Run executes the 3 visible sample tests below in your browser. Submit runs the full suite — including hidden tests — on the server for an official verdict.

  • Reference example: T = 4
  • Sample: single position T = 1
  • Sample: T = 7 full list