Need help in solving this FAANG interview question

This was an open ended question where I was left to decide the format of i/p.

Problem:
You are designing a voice recorder that can only record the highest dB spoken in a given time period.

  1. Given a list of time duration [start, end] and the db of people who spoke during each time duration, return a list of time range and the person who spoke the loudest in that time duration as multiple people can be talking at the same time.

  2. Each person speaks at the same dB everytime.

    Possible I/P format 1:
    [0,5]: 50dB
    [0,3]: 30dB
    [5,9]: 30dB
    [10,12]: 20dB
    [10,13]: 50dB

    Possible I/P format 2:
    50 dB: [0,5], [10,13]
    30 dB: [0,3], [5,9]
    20 dB: [10,12]

    O/P:
    [0,3]: 50
    [3,5]: 50
    [5,9]: 30
    [9,10]: 0
    [10,12]: 50
    [12,13]: 50

Any help in coming up with an efficient algorithm for the same would be truly appreciated! Thanks!

Comments (0)