FastPrepAlert After Repeated Column Threshold Breaches
Problems/Alert After Repeated Column Threshold Breaches

Alert After Repeated Column Threshold Breaches

Meta logoMeta● MediumFULLTIMEINTERNPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Two independent firsthand Meta reports describe a command-line monitor. It reads a chosen column and threshold settings from the arguments, then reads data like vmstat output from the input. A report from a Production Engineer Intern, dated January 31, 2024, says to warn only after the chosen value goes over the maximum the requested number of times in a row. This settles a point that a separate MLE report left open, since it only mentioned repeated breaches. We chose the exact flag names, the output text, how to handle bad rows, and the limits. Our version is about 88% the same as the reported question.

Write the main logic of a command-line monitoring script. Your function gets the command-line tokens as the array args and all of standard input as one string, stdinText.

args must hold exactly three flags, each followed by its value, in any order: --col C, --threshold T and --count X. Each flag appears exactly once. C is the column to watch, counting from one. T is an integer threshold. X is how many breaches in a row are needed for an alert.

Read standard input line by line and split each line on whitespace. Look at field C of each line. Skip the line if it has fewer than C fields, or if that field is not a nonnegative decimal integer. A skipped line does not change the current streak. This is how text headers in a vmstat-style stream get skipped.

The streak is the number of breaches in a row so far. For each valid value, a breach means value > T, strictly greater. A breach adds one to the streak. A value at or below T resets the streak to zero.

Return "WARNING" as soon as the streak reaches X. Return "" if the input ends first. Return "ERROR" if a flag is missing, repeated or unknown, if a flag has no value, or if a flag value is not a decimal number or is out of range.

Function

runThresholdAlert(args: String[], stdinText: String) → String

Examples

Example 1

args = ["--col", "4", "--threshold", "100", "--count", "2"]stdinText = "r b swpd free\n1 0 3 99\n2 0 3 101\n3 0 3 150\n"return = "WARNING"

The header line is skipped. The value 99 is not a breach, so the streak stays at zero. Then 101 and 150 are both above the threshold, one right after the other. That makes two breaches in a row, so the answer is "WARNING".

Example 2

args = ["--count", "2", "--threshold", "10", "--col", "2"]stdinText = "name value\na 11\nb 3\nc 12\nd 13\n"return = "WARNING"

The flags can come in any order. The header line is skipped. The first value is a breach, but the value 3 resets the streak to zero. The later values 12 and 13 are two breaches in a row, so the answer is "WARNING".

Example 3

args = ["--col", "2", "--threshold", "8", "--count", "2"]stdinText = "r b\na 9\nb bad\nc 10\n"return = "WARNING"

The header line is skipped. The line b bad is also skipped, because its field is not a number. Skipped lines do not reset the streak, so 9 and 10 count as two breaches in a row. The answer is "WARNING".

Example 4

args = ["--col", "0", "--threshold", "8", "--count", "1"]stdinText = "a 9\n"return = "ERROR"

The column is zero, but columns are counted from one, so the flag value is out of range. The answer is "ERROR".

Constraints

  • 1 <= C <= 20, 0 <= T <= 10^9, and 1 <= X <= 10^4.
  • 0 <= stdinText.length <= 100000. There are at most 10000 lines and at most 20 whitespace-separated fields per line.
  • A selected field is valid only if all its characters are ASCII digits and its value is at most 10^9. Other selected fields are skipped.
  • Input text is ASCII. Line breaks are LF or CRLF, and fields are separated by ASCII spaces or tabs.
  • Flag values must be nonnegative ASCII decimal integers with no signs or spaces inside them. Leading zeroes are allowed.

More Meta Phone Screen questions

  • Convert a Sorted Linked List to a Balanced BSTPHONE SCREEN · Seen Nov 2026
  • Fuzzy Word Lookup With One Misspelled LetterPHONE SCREEN · Seen Nov 2026
  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Run-Length Encoded Vector Dot ProductPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Mutual-Friend RecommendationsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Best Time to Buy and Sell StockPHONE SCREEN · Seen Nov 2026
  • First Element Greater Than KPHONE SCREEN · Seen Nov 2026
  • Count Events in Rolling Minute WindowsPHONE SCREEN · Seen Oct 2026
  • Valid Word AbbreviationPHONE SCREEN · Seen Oct 2026
  • Shortest Path in a Binary MatrixPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Query Log MatchDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions
  • Business Account KYC Verification — Parts 1–5Stripe · PHONE SCREENStripe interview questions
  • CSV Row SerializerMercor · PHONE SCREENMercor interview questions
  • Host Log ParserVerkada · PHONE SCREENVerkada interview questions
  • Length-Prefixed String CodecSnowflake · PHONE SCREENSnowflake interview questions
  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • HTTP Status Log SummaryApple · PHONE SCREENApple interview questions
  • JSON Identity VerificationKikoff · PHONE SCREENKikoff interview questions
  • Serialize a Nested Dictionary as JSONGoogle · PHONE SCREENGoogle interview questions
  • Render a Source-Backed Markdown SubsetSamsara · PHONE SCREENSamsara interview questions

Interview reports that mention this question

  • Meta Production Engineer Intern Questions: 6 Experiences

Meta interview experiences

  • Meta PhD SWE Intern AI Coding Phone Screen: 1 Experience
  • Meta Business Support Engineer Phone Screen: 1 Experience
  • Meta Software Engineer Onsite Questions: 3 Experiences
  • Meta AI Native Engineer OA and Onsite: 1 Experience
  • Meta AI-Native Coding Interview: 3 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public String runThresholdAlert(String[] args, String stdinText) {
        // Write your code here.
    }
}
Checking account…