As reported: CrowdStrike Senior Software Backend Engineer (Auth), 2026: a coding exercise given as C++ starter code. A class
Detectionholdsunique_id(string),risk_score(unsigned long) anddata(string), with a constructor and ato_string()that printsDetection(unique_id="...", risk_score=N, data="..."). Write the classDetectionStorewith a default constructor,void Put(const Detection&)to store a detection, andstd::unique_ptr<Detection> GetNext()that gets the next Detection to execute (based on risk score).
Implement DetectionStore:
DetectionStore()— an empty store.Put(detection)— store a detection.GetNext()— remove and return the next detection to execute: the one with the highest risk score. Return null (nullptr/None) when the store is empty.
Example
Put(Detection("d1", 40, "powershell spawn"))
Put(Detection("d2", 90, "credential dump"))
Put(Detection("d3", 40, "odd dns"))
GetNext() -> Detection(unique_id="d2", risk_score=90, data="credential dump")
GetNext() -> Detection(unique_id="d1", risk_score=40, data="powershell spawn")
GetNext() -> Detection(unique_id="d3", risk_score=40, data="odd dns")
GetNext() -> null
Clarifications
- Equal risk scores come out in the order they were
Put(first in, first out). - Unique ids are unique;
0 ≤ risk_score ≤ 10^15.
Constraints: up to 4 · 10^4 operations.
Code runner format: two lines, LeetCode-style: the operations ("DetectionStore", "put", "getNext") and their arguments ([uniqueId, riskScore, data] for put). The Detection class is provided in every language. Implement DetectionStore — C++: Put / GetNext returning std::unique_ptr<Detection>; Go: Constructor, Put, GetNext returning *Detection; Python / JavaScript / Java: put / getNext. The harness prints each returned detection's to_string() (or null).