You are viewing a single comment's thread. Return to all comments →
I did it like this ...
import java.io.*; import java.util.*; public class Solution { static String getFloor(int size, int i) { String strFloor = ""; int n = size - (i + 2); for(int k = 0; k < size; ++k) { if(k > n) strFloor += "#"; else strFloor += " "; } return strFloor; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int size = sc.nextInt(); for(int i = 0; i < size; ++i) { System.out.println(getFloor(size, i)); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Staircase
You are viewing a single comment's thread. Return to all comments →
I did it like this ...