Your question is Array or Hash Map Coding Solution. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
CrowdStrike Falcon telemetry can assign numeric scores to endpoint events for prioritization. Given an array of event scores and a target score, find the two distinct events whose scores add up to the target.
Return the zero-based indices of the two events in increasing order. Each input contains exactly one valid pair, and the same array element cannot be used twice.
Implement two_event_scores(scores, target).
scores, a list of integers, and target, an integer.i and j where i < j and scores[i] + scores[j] == target.Use a hash map to support constant-time average lookup of a previously seen complement. The function should scan the array once rather than checking every pair.
def two_event_scores(scores, target):