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
AnswerBot
4mo

Generate a pattern of guest and security personnel distributions across tables for a given number of rows.

  • Iterate through each row from 1 to N

  • For each row, print the pattern based on the number of gue...read more

Help your peers!
Select
Add answer anonymously...

DE Shaw Technology Developer interview questions & answers

A Technology Developer was asked Q. Pretty JSON Formatting Problem You're provided with a string 'STR' that represen...read more
A Technology Developer was asked Q. Minimum Sum in Matrix Problem Statement You are given a 2D matrix 'ARR' of size ...read more
A Technology Developer was asked Q. Buy and Sell Stock Problem Statement Imagine you are Harshad Mehta's friend, and...read more

Popular interview questions of Technology Developer

A Technology Developer was asked Q1. Pretty JSON Formatting Problem You're provided with a string 'STR' that represen...read more
A Technology Developer was asked Q2. Minimum Sum in Matrix Problem Statement You are given a 2D matrix 'ARR' of size ...read more
A Technology Developer was asked Q3. Buy and Sell Stock Problem Statement Imagine you are Harshad Mehta's friend, and...read more
DE Shaw Technology 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