Implement text formatter and sum subarray products
Company: Pika
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: Medium
Interview Round: Take-home Project
1) Text formatter (LC-inspired variant): Given an array of words and an integer maxWidth W >= 1, break the words into lines so that the total length of words on each line plus spaces is at most W. For every line except the last, place exactly one space between adjacent words, then append all remaining padding spaces after the final word so the line length is exactly W. The last line should be left-justified with single spaces between words and any remaining spaces appended at the end to reach W. Do not split words. Return the list of lines as strings and explain your algorithm and its time/space complexity.
2) Sum of subarray products: Given an integer array items[0..n-1], compute S = ∑_{i=0}^{n-1} ∑_{j=i}^{n-1} (∏_{k=i}^{j} items[k]). Return S.
Quick Answer: This question evaluates algorithmic problem-solving and implementation skills across string formatting (line breaking and space management) and array-based combinatorial computation (sum of subarray products), emphasizing correctness, edge-case handling, and analysis of time and space complexity.