WalmartLabs Coding Solution and Question
WalmartLabs Coding Solution and Question In recent interviews Walmart has comeup with a good questions which are being asked for Online coding on hacker rank. We have come up with coding algorithm & logic, so that it can be easy for you to solve coding challenge. Best luck 1. Given a number N. print in how many ways it can be represented as N = a+b+c+d , 1< =a< =b< =c< = d; 1<=N< = 5000 2. Given two number l and r (l<=r<=10^6) find most frequent digit among all prime numbers between l and r inclusive. if frequency is same print highest digit. Lets start immediately. Solution 1) What you want to find : number of ways a given number can be formatted. so see the observation Lets DP[n,k] be the number of ways to represent n as sum of k numbers. Then you are looking for DP[n,4]. For N = 4: Only 1 way - 1 + 1 + 1 + 1 For N = 5: Only 1 way - 1 + 1 + 1 + 2 For N = 6: 2 ways - 1 + 1 + 1 + 3 1 + 1 + 2 + 2 For N = 7: 3 ways - 1 + 1 + 1 + 4 1 + 1 + 2 + 3 1 + 2 + 2 + 2 For N = 8:Read full article from WalmartLabs Coding Solution and Question
No comments:
Post a Comment