Crazy Numbers Pattern Challenge

Ninja enjoys arranging numbers in a sequence. He plans to arrange them in 'N' rows such that:

  • The first row contains 1 number.
  • The second row contains 2 numbers.
  • The third row contains 3 numbers, and so on.

The numbers are placed in increasing order with an absolute difference of 1. Starting from 1 and continuing until 9, after which the sequence restarts from 1.

Input:

The first line contains 'T', representing the number of test cases. 
Each test case has a single integer 'N', indicating the number of rows.

Output:

For each test case, output the integers in the pattern for the next 'N' lines.

Example:

Input:
1 
4
Output:
   1 
23
456
7891

Constraints:

  • 1 <= T <= 10
  • 1 <= N <= 500

Note: The expected output is printed automatically; focus on implementing the function logic.

Saurabh Mishra
3mo
int N = 5; int counter = 1; for (int i = 1; i 9) counter = 1; } Console.WriteLine(); } Here Time complexity TC=> O(N^2) And SC => O(1)
Help your peers!
Add answer anonymously...
Nagarro Software 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