Skip to content

Commit 472be3f

Browse files
committed
Solution to print Full Numeric Pyramid
1 parent 523775c commit 472be3f

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package Scaler.Assignments;
2+
3+
public class FullNumericPyramid {
4+
public static void main(String[] args) {
5+
6+
printFullNumericPyramid();
7+
8+
}
9+
10+
static void printFullNumericPyramid(){
11+
12+
int totalRows = 5;
13+
14+
for (int row = 1; row <= totalRows; row++) {
15+
16+
int k = row;
17+
18+
for (int column = row; column <= totalRows-1; column++) {
19+
System.out.print(0 + " ");
20+
}
21+
22+
// System.out.print(row);
23+
for (int column = 1; column <= row; column++) {
24+
System.out.print(k + " ");
25+
k++;
26+
}
27+
28+
for (int column = k-2; column >= row; column--) {
29+
System.out.print(column + " ");
30+
// k--;
31+
}
32+
33+
for (int column = row; column <= totalRows-1; column++) {
34+
if (column == totalRows){
35+
System.out.print(0);
36+
}else {
37+
System.out.print(0 + " ");
38+
}
39+
}
40+
41+
System.out.println();
42+
}
43+
}
44+
}

‎src/Strings/Strings.java‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@ public static void main(String[] args) {
1010
System.out.println(output);
1111
}
1212

13+
static void firstOccurenceOfWord(String A, String B){
14+
15+
int lengthOfString = A.length();
16+
17+
for (int i = 0; i < lengthOfString; i++) {
18+
19+
for (int j = i+1; j < lengthOfString; j++) {
20+
21+
// if
22+
23+
}
24+
25+
26+
}
27+
}
28+
1329
static String reverseWordsInASentence(String S){
1430

1531
String [] array = S.split(" ");

0 commit comments

Comments
 (0)