-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstaircase.java
More file actions
39 lines (34 loc) · 1.03 KB
/
staircase.java
File metadata and controls
39 lines (34 loc) · 1.03 KB
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
/*
* Author: Sreenath T V
* https://www.hackerrank.com/challenges/plus-minus
*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class staircase {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner kbd = new Scanner(System.in);
int N;
N = kbd.nextInt();
String hashArr[] = new String[N];
String spaceArr[] = new String[N];
String tempHash = "";
String tempSpace = "";
for (int i = 0; i < N; i++) {
if (i == 0) {
tempHash += "#";
} else {
tempHash += "#";
tempSpace += " ";
}
hashArr[i] = tempHash;
spaceArr[i] = tempSpace;
}
for(int i = 0, j = N-1; i < N && j >= 0; i++, j--) {
System.out.println(spaceArr[j] + hashArr[i]);
}
}
}