-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaircase.java
More file actions
49 lines (25 loc) · 937 Bytes
/
Staircase.java
File metadata and controls
49 lines (25 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Challenge link : https://www.hackerrank.com/challenges/staircase/problem?isFullScreen=true
// Git Hub REPO Link : https://github.com/piyushpatelcodes/100-Days-Java-Hackerrank
import java.util.*;
import java.io.*;
public class Staircase{
public static void stair_pattern(int size) {
int level = size - 1;
for(int i = 0; i < size; i++) {
StringBuilder s = new StringBuilder();
for(int k = 0; k < level; k ++){
s.append(" ");
}
for(int k = 0; k< size - level; k++){
s.append("#");
}
level = level - 1;
System.out.println(s.toString());
}
}
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int size = sc.nextInt();
stair_pattern(size);
}
}