Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Staircase Hacker Rank Solution – Queslers

Problem: Staircase Hacker Rank Solution

Staircase detail

This is a staircase of size n=4


Its base and height are both equal to n . It is drawn using # symbols and spaces. The last line is not preceded by any spaces.

Write a program that prints a staircase of size n  .

Function Description

Complete the staircase function in the editor below.

staircase has the following parameter(s):

  • int n: an integer


Print a staircase as described above.

Input Format

A single integer,n , denoting the size of the staircase.



Output Format

Print a staircase of size  using # symbols and spaces.

Note: The last line must have  spaces in it.

Sample Input


Sample Output



The staircase is right-aligned, composed of # symbols and spaces, and has a height and width of n= 6.

Staircase Hacker Rank Solution Using Python


import math
import os
import random
import re
import sys

# Complete the staircase function below.
def staircase(n):
    for i in range(0,n):
        for j in range(0,n):
            if i + j >= n-1:
                print(" ",end='')

if __name__ == '__main__':
    n = int(input())


Staircase Hacker Rank Solution Using Java

import java.util.*;

public class Solution {
    public static void drawStair(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 ++){
            level -= 1;

    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 in = new Scanner(;
        Solution sol = new Solution();
        int size = in.nextInt();

Staircase Hacker Rank Solution Using C++

#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n - i - 1; ++j) {
            printf(" ");
        for (int j = n - i -1; j < n; ++j) {
    return 0;

Staircase Hacker Rank Solution Using C

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>

int main() {

    /* Enter your code here. Read input from STDIN. Print output to STDOUT */ 
    int height;
    int stair = height - 1;
    for (int i = 0; i < height; ++i){
        for (int j = 0; j < height; ++j){
            if (j >= stair){
            } else{
                printf(" ");
        stair -= 1;
    return 0;

Staircase Hacker Rank Solution Using JavaScript

function processData(input) {
    var steps = parseInt(input);
    for (var i = 0; i++ < steps; ) {
        var line = '';
        var spaces = steps - i;
        for (var j = spaces; j--; ) {
            line += ' ';
        for (var j = i; j--; ) {
            line += '#';

_input = "";
process.stdin.on("data", function (input) {
    _input += input;

process.stdin.on("end", function () {
Staircase Hacker Rank Solution Review:

In our experience, we suggest you solve this Staircase Hacker Rank Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

Staircase Problem is available on Hacker Rank for Free, if you are stuck anywhere between compilation, just visit Queslers to get Staircase Hacker Rank Solution.


I hope this Staircase Hacker Rank Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coursera Quiz Answers & Hacker Rank Solution.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Hacker Rank Solution >>

A Very Big Sum Hacker Rank Solution

Diagonal Difference Hacker Rank Solution

Leave a Reply

Your email address will not be published. Required fields are marked *