← Questions

Most relevant span of text by character scores

0
HebbiaCodingLast asked Apr 2025

You get a string and a relevance score (possibly negative) for each of its characters. Return the non-empty contiguous piece of the text whose scores add up to the most. On a tie, prefer the piece that starts earliest, then the shorter one. This is maximum subarray underneath: do it in one pass.

Write and test your solution herePython in your browser, the question's tests level by level, every submission kept for you.Sign in to start coding