Algorithm · ByteDance · Medium
Solve all four tasks below. Task 1 — Reverse word order Given a string s, reverse the order of its words and return the result. Spaces may appear at the beginning, at the end, or in consecutive runs between words. The returned string must contain exactly one space between adjacent words, with no leading or trailing spaces. Follow-up requirement: if the input is given as a mutable character array (char[]), modify it in place using no more than O(1) extra space. Task 2 —…
Checking your access…