Patterns: Interview Questions to Practice

Questions:
1. Triangle of numbers
Print the following pattern for the given number of rows.
Pattern for N = 3
1
232
34543Input format :Integer N (Total no. of rows)
Output format :Pattern in N lines
Sample Input :5
Sample Output :
1
232
34543
4567654
5678987652. Number Pattern
Print the following pattern
Pattern for N = 4
1
23
345
4567Input Format :N (Total no. of rows)
Output Format :Pattern in N lines
Sample Input :5
Sample Output :
1
23
345
4567
567893. Number Pattern 5
Print the following pattern for n number of rows.
For eg. N = 5
1 1
12 21
123 321
1234 4321
1234554321Sample Input 1 :4
Sample Output 1 :
1 1
12 21
123 321
123443214. Arrow Pattern
Print the following pattern for the given number of rows.
Assume N is always odd.
Note : There is space after every star.Pattern for N = 7
*
* *
* * *
* * * *
* * *
* *
*Input format :Integer N (Total no. of rows)
Output format :Pattern in N lines
Sample Input :11
Sample Output :
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * *
* * * *
* * *
* *
*5. Number Pattern
Print the following pattern
Pattern for N = 4
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 4Input Format :N (Total no. of rows)
Output Format :Pattern in N lines
Sample Input 1 :5
Sample Output 1 :
5 5 5 5 5 5 5 5 5
5 4 4 4 4 4 4 4 5
5 4 3 3 3 3 3 4 5
5 4 3 2 2 2 3 4 5
5 4 3 2 1 2 3 4 5
5 4 3 2 2 2 3 4 5
5 4 3 3 3 3 3 4 5
5 4 4 4 4 4 4 4 5
5 5 5 5 5 5 5 5 56. Print Pattern
Print the following pattern for the given number of rows.
Pattern for N = 5
1 2 3 4 5
11 12 13 14 15
21 22 23 24 25
16 17 18 19 20
6 7 8 9 10Input format : N (Total no. of rows)
Output format : Pattern in N lines
Sample Input :4
Sample Output :
1 2 3 4
9 10 11 12
13 14 15 16
5 6 7 87. Print Pattern (Mountain Pattern)
8. Print Pattern (Staircase Pattern)
9. Print Pattern (Diamond Pattern)
10. Print Pattern (Triangles in a Box)
