Sort by

recency

|

5200 Discussions

|

  • + 0 comments

    Here is Staircase solution in Python, Java, C++, C and javascript solution - https://programmingoneonone.com/hackerrank-staircase-problem-solution.html

  • + 0 comments

    Rust

    fn staircase(n: i32) {
            for number in 1..=n {
                let line = "#".repeat(number as usize);  
                println!("{:>width$}", line, width = n as usize );
            };
    }
    
  • + 0 comments

    public static void staircase(int n) { // Write your code here for(int i=0;i(n-2)) System.out.print("#"); else System.out.print(" ");

        }
        System.out.println();
    }
    
    }******
    
  • + 0 comments

    Starting from 0 will lead to a blank line, so start with 1. That's whart I was doing... lol

    for i in range(1, n+1):
            print(' '*(n-i)+'#'*i)
    				
    	
    
  • + 0 comments

    ** public static void staircase(int n) {

        for(int i=1;i<=n;i++)
        {
            for(int j=i;j<n;j++)
            {
               System.out.print(" ");
            }
    
            for(int j=i;j>=1;j--)
            {
               System.out.print("#");
            }
    
            System.out.println();
    
        }
    }**