Log Appeal Score
Preview mode. Log in to edit, run, submit, and save progress.
Log Appeal Score
A product log is analyzed by its substrings. The appeal of a substring is the number of distinct event codes appearing inside it. For every non-empty contiguous substring of the log, compute its appeal and add it to a global total. Repeated occurrences of the same code inside one substring contribute only once to that substring. Input Format: You are given a string s. Output Format: Return the total appeal score across all substrings.
Examples
s = "abbca"
28
Explanation: Appeal totals for substrings ending at each index are [1, 3, 4, 8, 12]. Their sum is 28, so the output is 28.
Approach hint
Track where each character last appeared.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.