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.
classResult{/* * Complete the 'staircase' function below. * * The function accepts INTEGER n as parameter. */publicstaticvoidstaircase(intn){// Outer loopfor(inti=1;i<=n;i++){// Printing Spacesfor(intj=1;j<=(n-i);j++){System.out.print(" ");}// Printing the required characterfor(intj=1;j<=i;j++){System.out.print("#");}// Changing line after each outer loop iterationSystem.out.println();}}}
Mail:
mst29310@gmail.com
Cookie support is required to access HackerRank
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 →
Java Solution (Complexity: O(n^2))
Mail: mst29310@gmail.com