Sort by

recency

|

5171 Discussions

|

  • + 0 comments
    for(int i = 1; i <= n; i++) {
        char[] array = [..Enumerable.Repeat(' ', n-i), ..Enumerable.Repeat('#', i)];
        Console.WriteLine(array);
    }
    
  • + 0 comments

    time Complexity = O(n)

    def staircase(n: int):
        for x in range(1, n + 1):
            print(" " * (n - x) + "#" * x)
    
  • + 0 comments

    Here is the website that published all the problems solutions - Programmingoneonone

  • + 0 comments
    def staircase(n):
        n_spaces = n - 1
        for i in range(1, n + 1):
            print(n_spaces * ' ' + i * '#')
            n_spaces -= 1
        
    if __name__ == '__main__':
        n = int(input().strip())
        staircase(n)
    
  • + 0 comments

    Java 15

    public static void staircase(int n) { int repeat = 1; for(int i=n ; i > 0; i-- ) { System.out.println(" ".repeat(i-1)+"#".repeat(repeat++)); }

    }