M-DAQ Interview Question

Coding question from leet code