Practice/mediumPalindrome Number Pattern
⏱ 00:00
Best: 0/100
Palindromes & Numeric SymmetryTarget Time: 15 mins

Palindrome Number Pattern

Given an integer N, print a centered palindrome pyramid where row i has leading spaces (2*(N - i)) followed by numbers decreasing from i down to 1, then increasing from 2 up to i, separated by space.

Input Format
A single integer N.
Output Format
Print N rows forming a palindrome pyramid.
Constraints:1 <= N <= 9
Concepts Required:
Dual sequence (descending + ascending)2*(N - i) leading spacingPalindrome sequence
Expected Pattern PreviewASCII Monospace
        1
      2 1 2
    3 2 1 2 3
  4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5

Notice how character spacing and row counts scale systematically based on the input N.

Concrete Examples

Example 1
Input:
5
Output:
        1
      2 1 2
    3 2 1 2 3
  4 3 2 1 2 3 4
5 4 3 2 1 2 3 4 5

Explanation: Each row reads identical backwards and forwards.

← Back to All Challenges