We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Algorithms
- Warmup
- Staircase
- Discussions
Staircase
Staircase
Sort by
recency
|
5196 Discussions
|
Please Login in order to post a comment
** public static void staircase(int n) {
// Use Java version 15. + First, I realized that the "#" character should be printed from 1 up to n each line. + Therefore, the number of spaces printed on each line equals n minus the number of "#" characters. + To reduce the number of System.out.println calls (which improves I/O effiency) we can use the StringBuilder with the repeat() method (available since Java 11).
// Source Code: public static void staircase(int n) { // Write your code here StringBuilder sb = new StringBuilder(); for (int i = 0 ; i< n ; i++) {
############################################################################################ ############################################################################################# ##############################################################################################
#For Python3 Platform
I wrote the code from scratch just to get more practice
c++ solution: