A dashboard lays out widgets in a grid of rows by cols. Keyboard focus starts on the top-left widget and must reach the bottom-right widget. Each key press moves focus one widget to the right or one widget down.
Write countFocusRoutes(rows, cols) that returns the number of different sequences of key presses that move focus from the top-left widget to the bottom-right widget.
Input: rows = 2, cols = 3 Output: 3
Right-right-down, right-down-right, or down-right-right.
Input: rows = 3, cols = 3 Output: 6
Any order of 2 rights and 2 downs: there are 6.
1 <= rows, cols <= 16Run tries your code on the examples. Submit runs every test, including hidden edge cases, and solves the problem when they all pass.
Ctrl + Enter runs, Ctrl + Shift + Enter submits (⌘ on a Mac).
I'm here to help with #487 Focus Routes Across a Widget Grid. I give hints, never the solution, so you get to solve it yourself. Ask for a hint, select code to ask about it, or press Ask Tuto why on a failing test.
Your first 3 answers need no account. for free to keep asking.