Ninja's Pattern with Powers of 2
Ninja, who loves playing with numbers, sets out to arrange numbers within 'N' rows. The unique arrangement follows these rules: the first row contains 1 number, the second row contains 2 numbers, and the third, 4 numbers, continuing this pattern of powers of 2.
He fills these patterns with numbers in increasing sequence, beginning from 1 up to 9, and upon reaching 9, recycles back to 1.
Your task is to produce the pattern for a given number 'N' of rows.
Example:
Input:
T = 1
N = 4
Output:
1
23
4567
89123456
Constraints:
- 1 ≤ T ≤ 5
- 1 ≤ N ≤ 15
Time Limit: 1 sec
AnswerBot
1d
Generate a pattern of numbers in rows following a powers of 2 sequence with numbers 1 to 9, recycling back to 1.
Start with 1 number in the first row, 2 numbers in the second row, 4 numbers in the thir...read more
Help your peers!
Add answer anonymously...
Popular interview questions of Software Engineer
Top HR questions asked in RadiSys Software Engineer
Stay ahead in your career. Get AmbitionBox app
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
Get AmbitionBox app