Tiling Problem in JAVA
- oanaunciuleanu

- 22 nov. 2022
- 1 min de citit
You can use a board that is 2 x n size. The tiles are of size 2 x 1. Count the number of ways to tile the board. Tiles can be placed vertically 2 x 1 or horizontally as 1 x 2.
Solution:
1. static int getNoOfWaysToTile(int board) { 2. if (board <= 2) { 3. return board; 4. } 5. return getNoOfWaysToTile(board - 1) + getNoOfWaysToTile(board - 2); 6. } 7.

Comentarii