Emit Threshold Warning on Metric Breaches

Asked at Meta · Coding Questions · Difficulty: Easy

You are given metric log lines (each split on whitespace into columns), a 1-indexed column number `col`, a numeric `threshold`, and a required breach `count`. Scan the lines in order: skip a line that has no column `col` or whose column `col` value is non-numeric; when the numeric value in column `col` exceeds `threshold`, count a breach. As soon as the breach count reaches `count`, return the warning string `"WARNING: column {col} exceeded {threshold} at least {count} times"`. If it is never reached, return `""`.

Loading the problem…