← 返回 nvidia 的题目列表Systems Utility Coding: Temperature Spike, Logs, Brackets
类型:qbank
System Software rounds use short utility tasks: detect a temperature spike from `(timestamp, cpu_temp)` pairs, validate brackets in an expression, aggregate logs by status code and latency, or minimize an array sum after K greedy reductions.
Requirements
This family appears as several short prompts in the same loop.
Temperature spike detection
Input: ordered pairs (timestamp, temperature). Return the timestamp(s) or interval(s) where CPU temperature spikes. Clarify the spike definition:
Absolute jump: temp[i] - temp[i-1] >= threshold.
Rolling baseline: temp[i] > avg(previous window) + threshold.
Sustained spike: at least k consecutive high readings.
Bracket validation
Implement:
def is_valid_expression(expr: str) -> bool:
...
Support (), [], {} inside arbitrary mathematical text.
Log aggregation
Input records contain status code and response time. Output per status code:
Count.
Average response time.
Optional top-N slowest or most frequent statuses.
Minimum Sum after K operations
Given an integer array and k, repeatedly choose an element, replace it with ceil(x / 2), and return the minimum possible sum after k operations.
Notes
The utility prompts are easy algorithmically but must be production-clean: define input shape, clarify thresholds, and handle empty data.
Minimum Sum is a max-heap problem. Each operation should reduce the current largest value because replacing x with ceil(x / 2) saves floor(x / 2), which is monotonic in x. Complexity is O((N + K) log N).
Log aggregation is a hashmap from status -> (count, total_ms); average is computed at the end. Avoid integer division bugs.
Preparation
Practice writing small parsers and aggregators with explicit edge cases.
For ambiguous monitoring prompts, ask for the anomaly definition before coding.
Implement Minimum Sum with a max-heap in Python and C++.