Quant Memo
Coding/●●●●●

Reverse the fields of a log line

An execution log line has space-separated fields, sometimes with irregular spacing. Reverse the order of the fields and join them with single spaces, dropping any leading, trailing, or repeated spaces.

line = "FILL   100 AAPL"
-> "AAPL 100 FILL"

Return the fields in reverse order, single-spaced. Aim for O(n)O(n).

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions