Number Pattern Program

Write a program that takes an integer N as input and prints a specific pattern for N lines.

Example:

Input:
N=3
Output:
[[1, 2, 3, 10, 11, 12], [4, 5, 8, 9], [6, 7]]
Explanation:

For N=3, the pattern is created as follows:
First row: 1 2 3 10 11 12
Second row: 4 5 8 9
Third row: 6 7
Each list within the 2D list represents a row in the pattern.

Constraints:

  • 1 <= N <= 1000
  • Time Limit: 1 second
AnswerBot
4mo

The program takes an integer N and prints a specific number pattern for N lines.

  • Create a 2D list to store the pattern rows

  • Use loops to generate the numbers in each row based on the pattern

  • Print the 2D...read more

Help your peers!
Select
Add answer anonymously...
REACH Technologies Software Developer Intern 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