Thomson Reuters interview question

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