Binary Pattern

You have been given an input integer 'N'. Your task is to print the following binary pattern for it.

Example

Pattern for 'N' = 4

1111
000
11
0

The first line contains 'N' 1s. The next line contains 'N' - 1 0s. Then the next line contains 'N' - 2 1s and so on.

Input format :
The first line of input contains an integer 'T' that denotes the number of test cases.

The first line of each test case contains a single integer 'N'.
Output format :
For each test case, print 'N' lines containing the pattern, each of the 'I-th' lines should contain 'N' - 'I' + 1 number depending on the 'I' value. 
Constraints :
1 <= T <= 10
1 <= N <= 10^3

Time Limit: 1 sec
CodingNinjas
author
2y
Iterative

In the pattern, every even-numbered line is filled with 0's, and the odd-numbered line is filled with 1's and we have total N lines.

We can run a for loop from 0 to N for each line and insid...read more

Help your peers!
Add answer anonymously...
TCS System Engineer 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
Get AmbitionBox app

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