Complete the function below. The function receives the full standard input as a single string and must return the exact standard output lines for the described problem.
Original prompt
Problem: Email Log Processing (Grouping + Rule-based Sorting)
You are given a list of email event logs logs. Each log is a single line string in the format:
<timestamp> <sender_email> <receiver_email> <subject>
timestamp: a non-negative integer (seconds since epoch) sender_email, receiver_email: strings without spaces subject: the remainder of the line starting from the 4th token; it may contain spaces (and may be empty)
Your task is to group logs by sender_email, sort each group by specific rules, and print the result.
Rules
Group by sender_email. Within the same sender_email, sort logs by: timestamp ascending if equal, receiver_email lexicographically ascending if still equal, subject lexicographically ascending Output sender groups in lexicographical order of sender_email.
Input
Line 1: integer n, number of logs. Next n lines: one log per line.
Output
For each sender, print:
sender: <sender_email>
Then print each sorted log line as:
<timestamp> <receiver_email> <subject>
Note: sender_email is not printed on the log lines.
Constraints
1 <= n <= 2 * 10^5 0 <= timestamp <= 10^9 Each line length <= 300 Example
Input
5 100 alice@a.com bob@b.com hello 90 alice@a.com carl@c.com meeting notes 90 dan@d.com e@e.com hi 90 alice@a.com bob@b.com a-subject 100 dan@d.com a@a.com ping
Output
sender: alice@a.com 90 bob@b.com a-subject 90 carl@c.com meeting notes 100 bob@b.com hello sender: dan@d.com 90 e@e.com hi 100 a@a.com ping
Complete solveEmailLogGroupingAndSorting. It has one parameter, String input, containing the full stdin payload. Return the stdout payload as an array of lines, without trailing newline characters.
input = "1\n0 a@a.com b@b.com hi" return = ["sender: a@a.com", "0 b@b.com hi"]
The returned string must match the expected standard output for the sample input.
Use the limits and requirements stated in the prompt.
- Account Balance Manager Part 3 - Platform CoverageONSITE INTERVIEW · Seen Jun 2026
- BitFont Part 3 - Decode Run-Length-Encoded RowsONSITE INTERVIEW · Seen Jun 2026
- Record Linkage Part 3 - Full Connected ComponentPHONE SCREEN · Seen Jun 2026
- Shipping Cost Calculator Part 3 - Mixed Fixed/Incremental TiersONSITE INTERVIEW · Seen Jun 2026
- Transaction Fee Calculator - Per-Merchant Volume DiscountPHONE SCREEN · Seen Jun 2026
- Account Balance Manager Part 2 - Reject OverdraftsONSITE INTERVIEW · Seen Jun 2026
- BitFont Part 2 - Render a WordONSITE INTERVIEW · Seen Jun 2026
- Factory Cost - Min-Cost Path Skipping One StagePHONE SCREEN · Seen Jun 2026
public String[] solveEmailLogGroupingAndSorting(String input) {
// write your code here
}