Color a Grid with No Monochromatic Row or Column
Updated
Problem statement
Color every cell of a 3 by n grid with one of three labeled colors. No entire row and no entire column may consist of a single color. Adjacent cells may have equal colors as long as these whole-row and whole-column conditions hold. Return the number of colorings modulo 1000000007.
Function
countColorings(n: int) → intExamples
Example 1
n = 1return = 0Each length-one row would be monochromatic.
Example 2
n = 2return = 174There are 174 colorings with all three rows using both positions differently and no monochromatic column.
Constraints
- 1 <= n <= 20000. All three colors are available for every cell.
More Intuit Online Assessment questions
- Employee Promotion OpportunitiesOA · Seen Oct 2026
- Next Pascal Row CoefficientOA · Seen Oct 2026
- Parse Router LogsOA · Seen Oct 2026
- Longest Repeated Letter Block with Adjacent SwapsOA · Seen Oct 2026
- Maximum Square-Free DivisorOA · Seen Oct 2026
- Two Tribes from Taller-Person CountsOA · Seen Oct 2026
- Shortest Path from an Encoded GraphOA · Seen Sep 2026
- Oldest and Youngest EmployeesOA · Seen Sep 2026
- Pressure-Isolation Shutdown OrderOA · Seen Sep 2026
- Submask Sum QueriesOA · Seen Sep 2026
Similar questions at other companies
- Frog Paths Without Long RunsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
- Get Triplet CountIBM · OAIBM interview questions
- Sum of Pipeline Response TimesBloomberg LP · OABloomberg LP interview questions
- Count Numbers with the Same Set-Bit CountMicrosoft · OAMicrosoft interview questions
- Count Reverse-Digit PairsVisa · OAVisa interview questions
- Get Triplet CountPoint72 · OAPoint72 interview questions
- Count Shipment SchedulesMorgan Stanley · OAMorgan Stanley interview questions
- Product of Subset MaximaArcesium · OAArcesium interview questions
- Find Maximum Number of Balanced CombinationsAmazon · OA
- Exactly K Preferred Role AssignmentsIMC Trading · OAIMC Trading interview questions