
Asked in Nagarro
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.

AnswerBot
4mo
Arrange numbers in a sequence in 'N' rows with increasing order and repeating after 9.
Iterate through each test case and for each row, print numbers in increasing order with a loop.
Keep track of the c...read more
Saurabh Mishra
9mo
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...
Top Software Developer Interview Questions Asked at Nagarro
Q. Design and implement a data structure for Least Recently Used (LRU) cache. It sh...read more
Q. Given the root of a binary search tree, and an integer k, return the kth smalles...read more
Q. What is abstraction in Java?
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for Nagarro Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

