SAP Off Campus Hiring_ March 2015 Coding Skills

Question # 1

Complete the code to solve the following problem statement
Given two integers N and M (0 <= N <= M <= 10 7), find the sum of digits of all integers from N to M, both inclusive. Example: Input: 1 10 Output: 46





Question # 2
Planning the street
King Kohima has reserved a new exclusive street for his executive class employees where they can build their homes. He has assigned you to plan that street. You have to decide on which plots along the street are new building allowed to be built. In order to this, you first want to calculate the number of possible ways of assigning free plots to buildings while keeping in mind this restriction - No two consecutive plots can have buildings on them. This is done to ensure a sense of free space in the arena. The street is divided in M sections. Each section corresponds to 2 plots, one on each side of the street. Find the number of possible assignments. Input In the first line you're given M ( M ≤ 1000 ). Output In the first and only line output the result/ Example Input: 3 Output: 25 Example explanation: If we just look at the one street side and mark X as a plot where building is allowed and Y as a free plot, we have: XYX, YXY, YYX, XYY, YYY. Since the same number exists on the other side, we have 5*5 = 25 combinations.

If you want to share such question , solution  or your experience of any company, Please do share at admin@gohired.in , As sharing is caring





Book TO be Used to solve such questions :