Rectangular Numbers Problem Statement

Ninja has a number 'N'. Your task is to generate a pattern where the outer rectangle is filled with the number 'N', and as you move inward, the numbers decrease consecutively.

Example:

Input:
N = 4
Output:
4 4 4 4 4 4 4 
4 3 3 3 3 3 4
4 3 2 2 2 3 4
4 3 2 1 2 3 4
4 3 2 2 2 3 4
4 3 3 3 3 3 4
4 4 4 4 4 4 4

Constraints:

  • 1 <= T <= 5
  • 1 <= N <= 100
  • Time limit: 1 sec.
Note:
You do not need to input or print anything, and it has already been taken care of. Just implement the given function.
AnswerBot
4d

Generate a pattern with outer rectangle filled with number 'N' and decreasing consecutively inward.

  • Start by filling the outermost rectangle with the number 'N'.

  • Decrease the numbers consecutively as yo...read more

Help your peers!
Add answer anonymously...
Athenahealth Technology 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