Occurrences of a Number

Revision en1, by rahul_1234, 2017-05-16 23:22:52

Problem: Write a method that, given a digit 'd' and number of its occurences 'k', returns a range which has that many occurrences of d. More precisely, return a lower and upper bound of this number N.

Example:

input: d=4, k=1

output {4, 13}

Range: 4-14

input: d=4, k=0

output {1, 3} Range: 1-3

Can anybody help me in this?

Tags binary search

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English rahul_1234 2017-05-16 23:22:52 384 Initial revision (published)