Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
LeetCode 790: Domino and Tromino Tiling β€” DP Explained (O(1) Space)
Play lesson

LeetCode 75 C++ | Step-by-Step Solutions (LAN Academy) - LeetCode 790: Domino and Tromino Tiling β€” DP Explained (O(1) Space)

4.0 (1)
12 learners

What you'll learn

This course includes

  • 5.5 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

Solve LeetCode 790 β€” Domino and Tromino Tiling using Dynamic Programming. We want the number of ways to tile a 2 Γ— n board using: Domino (2Γ—1) tiles (rotations allowed) Tromino (L-shape) tiles (rotations allowed) DP Idea A clean way is to use two states: full[i] = ways to fully tile a 2Γ—i board gap[i] = ways to tile a 2Γ—i board with one cell missing (a β€œstaggered” board) Recurrences: full[i] = full[iβˆ’1] + full[iβˆ’2] + 2Β·gap[iβˆ’1] gap[i] = gap[iβˆ’1] + full[iβˆ’2] All answers are computed mod 1e9+7. (You can also derive the well-known single recurrence: full[i] = 2Β·full[iβˆ’1] + full[iβˆ’3], for i β‰₯ 3.) Complexity Time: O(n) Space: O(1) (rolling variables) If this helped, subscribe for more DP patterns and interview problems. #LeetCode #DynamicProgramming #Algorithms #codinginterview #leetcode #leetcodecoding #leetcodesolution #leetcodechallenge #faang #fang #computerscience #cs #codingtiktok #coding #codinglife #boostofhope #fyp #codinginterview #softwareengineer #swe #tech #foryou #python #learntocode #google #techtok #programming #algorithms #learntocode

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere