Блог пользователя Master_coder

Автор Master_coder, история, 5 лет назад, По-английски

Given N keys and values , and q queries for each query you have given key you have to find key smaller than given key with maximun value . for example:- keys — 2 3 1 6 4 values — 5 1 6 2 8 given key 5 must produce output 8 i.e (4,8)

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
5 лет назад, # |
  Проголосовать: нравится +7 Проголосовать: не нравится

Sort the keys. Make another array that Max. Max[I] will store the maximum value till index I. You can search the index where the key is just smaller than the input key with lower_bound. Let the index is Ind then the answer is nothing but Max[Ind].