Code Room
CodingMediumcod-g025
Subject Dynamic programming 1dLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

You have an unlimited supply of 2x1 dominoes and L-shaped trominoes (a tromino covers three cells in an L). Count the number of ways to fully tile a 2 x n board; two tilings are different if some cell is covered by a different shape. Because the count grows fast, return the answer modulo 1_000_000_007. Assume 0 <= n <= 1000.

Implement
num_tilings(n: int) → int
Examples
in[3]out5
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.