File tree Expand file tree Collapse file tree 2 files changed +67
-66
lines changed Expand file tree Collapse file tree 2 files changed +67
-66
lines changed Original file line number Diff line number Diff line change
1
+ # [ Staircase] ( https://www.hackerrank.com/challenges/staircase )
2
+
3
+ Difficulty: #easy
4
+ Category: #warmup
5
+
6
+ Staircase detail
7
+ This is a staircase of size $ n = 4 $:
8
+
9
+ ``` text
10
+ #
11
+ ##
12
+ ###
13
+ ####
14
+ ```
15
+
16
+ Its base and height are both equal to n. It is drawn using # symbols
17
+ and spaces. The last line is not preceded by any spaces.
18
+
19
+ Write a program that prints a staircase of size n.
20
+
21
+ ## Function Description
22
+
23
+ Complete the staircase function in the editor below.
24
+
25
+ staircase has the following parameter(s):
26
+
27
+ * int n: an integer
28
+
29
+ ## Print
30
+
31
+ Print a staircase as described above.
32
+
33
+ ## Input Format
34
+
35
+ A single integer, , denoting the size of the staircase.
36
+
37
+ Constraints
38
+
39
+ $ 0 < n \leq 100 $
40
+
41
+ ## Output Format
42
+
43
+ Print a staircase of size n using # symbols and spaces.
44
+
45
+ Note: The last line must have spaces in it.
46
+
47
+ ## Sample Input
48
+
49
+ ``` text
50
+ 6
51
+ ```
52
+
53
+ ## Sample Output
54
+
55
+ ``` text
56
+ #
57
+ ##
58
+ ###
59
+ ####
60
+ #####
61
+ ######
62
+ ```
63
+
64
+ ## Explanation
65
+
66
+ The staircase is right-aligned, composed of # symbols and spaces,
67
+ and has a height and width of $ n = 6 $.
Original file line number Diff line number Diff line change 1
- /**
2
- * Staircase
3
- *
4
- * https://www.hackerrank.com/challenges/staircase
5
- *
6
- * Difficulty: #easy
7
- * Category: #warmup
8
- *
9
- * Staircase detail
10
- * This is a staircase of size n = 4:
11
- * ```
12
- * #
13
- * ##
14
- * ###
15
- * ####
16
- * ```
17
- *
18
- * Its base and height are both equal to n. It is drawn using # symbols
19
- * and spaces. The last line is not preceded by any spaces.
20
- *
21
- * Write a program that prints a staircase of size n.
22
- *
23
- * # Function Description
24
- *
25
- * Complete the staircase function in the editor below.
26
- *
27
- * staircase has the following parameter(s):
28
- *
29
- * * int n: an integer
30
- *
31
- * # Print
32
- * Print a staircase as described above.
33
- *
34
- * # Input Format
35
- * A single integer, , denoting the size of the staircase.
36
- *
37
- * Constraints
38
- *
39
- * 0 < n <= 100
40
- *
41
- * # Output Format
42
- *
43
- * Print a staircase of size n using # symbols and spaces.
44
- *
45
- * Note: The last line must have spaces in it.
46
- *
47
- * # Sample Input
48
- * ```
49
- * 6
50
- * ```
51
- *
52
- * # Sample Output
53
- * ```
54
- * #
55
- * ##
56
- * ###
57
- * ####
58
- * #####
59
- * ######
60
- * ```
61
- *
62
- * # Explanation
63
- * The staircase is right-aligned, composed of # symbols and spaces,
64
- * and has a height and width of n = 6.
65
- */
66
-
67
1
export function staircase ( n : number ) : string {
68
2
const result : string [ ] = [ ] ;
69
3
You can’t perform that action at this time.
0 commit comments