X

DAYS

:

HOUR

:

MINS

:

SEC

Copied to Clipboard
Number Pattern
School Accuracy: 53.99% Submissions: 791 Points: 0

For a given number N. Print the pattern in the following form: 1 121 12321 1234321 for N = 4.

Example 1:

Input:
N = 3
Output:
1 121 12321
Explanation:
For N = 3 we will print the 3 strings
according to the pattern.

Example 2:

Input:
N = 6
Output:
1 121 12321 1234321 123454321 12345654321
Explanation:
For N = 6 we will print the 6 strings
according to the pattern.

You don't need to read input or print anything. Your task is to complete the function numberPattern() which takes an integer N as input parameter and returns the list of strings to be printed.

Expected Time Complexity: O(N2)
Expected Auxiliary Space: O(1)

Constraints:
1 ≤ N ≤ 200

We are replacing the old Disqus forum with the new Discussions section given below.

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Number Pattern