Skip to content

Instantly share code, notes, and snippets.

@akinjide
Created March 2, 2018 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akinjide/94ae8d417572c996c6ee248c305a7d3b to your computer and use it in GitHub Desktop.
Save akinjide/94ae8d417572c996c6ee248c305a7d3b to your computer and use it in GitHub Desktop.
Staircase problem implemented in JavaScript
// Time Complexity O(n2)
const staircase = (n, c) => {
let y = [];
let s;
for (let i = 1; i <= n; i++) y[i - 1] = i;
for (let j = 1; j <= n; j++) {
s = y.length - j;
console.log(' '.repeat(s), c.repeat(j));
}
}
staircase(6, '#');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment