Number Pattern Generator

To arrange a high-security meeting, tables are set up for delegates and security personnel. There are N rows of tables. The first row has one table, the second row has two tables, and so on, incrementing by one for each subsequent row. To maximize security, the tables on each end of a row are reserved for security personnel. If a row only has one table, it is assigned solely to a security personnel. Tables designated for security personnel accommodate one person each, while the remaining tables host two guests each.

Your task is to generate and display the pattern of guest and security personnel distributions across the tables for a given number of rows.

Example:

Input:
N = 4
Output:
1
11
121
1221
Explanation:

For each row, print the pattern that reflects the number of guests or security personnel at each table.

Constraints:

  • 1 ≤ T ≤ 10: the number of test cases
  • 1 ≤ N ≤ 10^3: the number of rows
  • Time Limit: 1 sec
Be the first one to answer
Add answer anonymously...
DE Shaw Technology Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

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

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter