Geeksforgeeks

Error

×

Leaderboard

Showing:

Handle | Score |
---|---|

@Ibrahim Nash | 5725 |

@blackshadows | 5685 |

@akhayrutdinov | 5111 |

@mb1973 | 4989 |

@Quandray | 4908 |

@saiujwal13083 | 4156 |

@sanjay05 | 3762 |

@marius_valentin_dragoi | 3511 |

@sushant_a | 3453 |

@KshamaGupta | 3318 |

@the_coder95 | 3302 |

Complete Leaderboard | |

Handle | Score |

@avaiesshaik782 | 662 |

@arpitsatnalika | 629 |

@code_it_ | 591 |

@prakharxyz | 583 |

@tujhekya | 542 |

@Rahul Jadhav 1 | 458 |

@sivanandh03 | 448 |

@satyam0460 | 429 |

@iamronak | 424 |

@imnm | 424 |

@18eumc107 | 421 |

Complete Leaderboard |

You a given a number **N**. You need to print the pattern for the given value of **N**.

for **N = 2** the pattern will be

2 2 1 1

2 1

for **N = 3** the pattern will be

3 3 3 2 2 2 1 1 1

3 3 2 2 1 1

3 2 1

**Example 1:**

**Input: **2**
Output:
**2 2 1 1 $2 1 $**
**

**Example 2:**

**Input: **3**
Output:
**3 3 3 2 2 2 1 1 1 $3 3 2 2 1 1 $3 2 1 $**
**

**Your Task:**

Since this is a function problem, you don't need to worry about the testcases. Your task is to complete the function** ****printPat**** **which takes one argument 'N' denoting the length of the pattern.

**Note :**** **Instead of printing new line print a **"$"** without quotes.

**Constraints:**

1 <= N <= 40

**Note:**The **Input/Ouput** format and **Example** given are used for system's internal purpose, and should be used by a user for **Expected Output** only. As it is a function problem, hence a user should not read any input from stdin/console. The task is to complete the function specified, and not to write the full code.

Login to report an issue on this page.

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

Yes
Print the pattern | Set-1

...

Please choose 'ReadOnlyMode' if you needn't to 'Edit' the problem e.g. viewing OJ's solution, TestCase Files (TCFs), TimeLimit etc.