Tiling Problem Statement

Given a board with 2 rows and N columns, and an infinite supply of 2x1 tiles, determine the number of distinct ways to completely cover the board using these tiles.

You can place each tile:
1. Horizontally as a 1x2 tile
2. Vertically as a 2x1 tile

Input:

N

Output:

The number of ways to tile the board modulo 10^9 + 7

Example:

Input:
N = 4
Output:
5

Explanation:

The image shows an example of possible tile arrangements for a board size of N = 4. The board is completely covered using the available tiles in multiple distinct configurations.

Constraints:

  • 1 <= N <= 1018
  • Time limit: 1 sec
Note:
You are not required to print the output explicitly, just implement the function as the printing is handled by the system.
AnswerBot
4mo

The problem involves finding the number of ways to tile a 2xN board using 2x1 tiles.

  • Use dynamic programming to solve this problem efficiently.

  • Define a recursive function to calculate the number of way...read more

Nikita Tiwari
2y

class solution {

static int getNoOfWays(int n)

{

// Base case

if (n <= 2) {

return n;

}

return getNoOfWays(n - 1) + getNoOfWays(n - 2);

}

// Driver Function

public static void main(String[] args)

{

...read more

Help your peers!
Select
Add answer anonymously...

GlobalLogic Software Developer interview questions & answers

A Software Developer was asked 2mo agoQ. You have the following two tables: Table: Orders | OrderID | CustomerID | OrderD...read more
A Software Developer was asked 7mo agoQ. Write a program to generate the Fibonacci sequence.
A Software Developer was asked 8mo agoQ. Write code to find the length of a string.

Popular interview questions of Software Developer

A Software Developer was asked 7mo agoQ1. Write a program to generate the Fibonacci sequence.
A Software Developer was asked 8mo agoQ2. Write code to find the length of a string.
A Software Developer was asked 10mo agoQ3. Explain the React component lifecycle.

Top HR questions asked in GlobalLogic Software Developer

A Software Developer was asked 6mo agoQ1. Can you tell me about yourself?
A Software Developer was asked 6mo agoQ2. What do you know about our company?
A Software Developer was asked 6mo agoQ3. Tell me about yourself?
GlobalLogic Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits