OA Glider.ai | Bengaluru | 2yrs experience
Anonymous User
399

First of all, horrible website. The complier is giving error with no clue as to why the error is happening.
Second, shitty UI, but okay compared to others. I really went squint to read the question properly.

2 Questions, no breaks in between:

  1. Array [Easy] : Find the number digits needed to store a number as a sum of all the number before it.
n = 7
sum = 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28
digits = 2 as 28 has to digits
  1. DP [Medium]: Find the minimuim number of steps needed to reach a friends house by taking 1,2,3,4 or 5 steps at once
n = 13
n = 5 + 5 + 3
steps = 3

dp = min({pick(n - 1), pick(n-2), pick(n-3), pick(n-4), pick(n-5)});
Variation of coin change but with the cost of picking each step same.
Greedy also works. Any number can be reduced by this denominations. But wouldn't generate the minimum number of denominations. Just one/more denominations that work!
Comments (1)