Hackerrank Problem: Staircase
Upon my job search, I have realized that I need to become a bag of all trades whether it be exposing myself to new frameworks like Vue.js, Angular, or simply doing not just Leetcode problems but HackerRank as well…
This past week I attended an info session for JP Morgan Chase & Co.’s emerging talent software engineer program. Once of the steps in the process is a HackerRank problem. I have since then decided that I will be exposing myself to both HackerRank and Leetcode not that there’s much of a difference. I just feel the needed to familiarize myself with the IDE and I guess the “sort” of problems HackerRank has and pray to the Coding gods that I can really show my stuff in this potential job opportunity.
So lo’ and behold! A HackerRank problem!!! This was quite easy. Again, I feel the doom of forgetting useful built-in methods. Let’s look at the problem first.
Well, basically in this problem, we need to create a staircase using the “#” symbol. Seems easy enough.
n is representative of an integer.
I can do a simple loop starting at 1and repeat the symbol that many times and use a method called padStart which takes in the integer representing the size of the staircase. padStart() is a string method that is used to pad the start of a string with a specific string to a certain length.
I hope this brings some clarity. I am so use to start my loops at 0 that my top of the staircase was empty and failing the test cases. After changing it start at 1, only then my solution passed the test cases. Just something to keep in mind when doing problems like these!