Thomson Reuters Interview Question

Coding question on hackerrank, then asked for time/space complexity