Occurrences of a Number

Правка en1, от 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?

Теги binary search

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский rahul_1234 2017-05-16 23:22:52 384 Initial revision (published)