Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 6 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 17 Sep 2017 My Price 10.00

conquer Dholakpur

Bheem and his friends were playing with numbers in the jungle but suddenly there came a storm, all the trees started displacing from their places, animals running here and there to survive the storm. Yes it was Kirmada back again to conquer Dholakpur, the only kingdom left in the world that was not conquered by him. He challenged Bheem again to save Dholakpur as this time Kirmada was even stronger than earlier, but this time the challenge was not to fight against him to save Dholakpur but the challenge was with numbers.
With his magical power Kirmada concatenated all the number from 1 to N and gave Bheem a number k and challenged him to tell the digit at kth index in the concatenated number. Help Bheem win this challenge and save Dholakpur.

 

Input

    • The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.

 

  • Next T contains 2 space-separated integers N and k

 

Output

  • For each test case, output a single line containing the kth digit (1-based indexing) in the concatenated number.

 

Constraints

  • 1 = T = 100000
  • 1 = N = 10^15
  • 1 = k = the length of concatenated number

 

Example

Input: 2 10 5 15 16 Output: 5 1

 

Explanation

Example case 1. concatenating all numbers from 1 to 10 gives 1234567810 and the 5th digit in the concatenated number is 5.
Example case 2. concatenating all numbers from 1 to 15 gives 123456789101112131415 and the 16th digit in the concatenated number is 1.

Note: The problem originally belongs to one of the Google Interview Questions.

Answers

(5)
Status NEW Posted 17 Sep 2017 12:09 PM My Price 10.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)