I need to build an algorithm to merge time intervals from multiple arrays (for simplification considering only one date) while keeping input id information. What are some approaches to do it?
Input:
{"input_id": "1", "ranges": [{"from": 07:00, "to": 13:00}, {"from": 15:00, "to": 15:30}],
{"input_id": "2", "ranges": [{"from": 08:00, "to": 14:30}]}
Expected output:
{"ranges":[
{"from": 07:00, "to": 08:00, "inputs": [1]},
{"from": 08:00, "to": 13:00, "inputs": [1,2]},
{"from": 13:00, "to": 14:30, "inputs": [2]},
{"from": 15:00, "to": 15:30, "inputs": [1]},
]}