Loading...
You are given an array of field values fields, each a non-empty string. Classify every field as exactly one of four types, checked in this order:
int: an optional leading - followed by 1 to 18 digits (nothing else).bool: the word true or false, compared case-insensitively.date: exactly the shape DD/MM/YYYY (two digits, two digits, four digits separated by /) that forms a valid calendar date: month 01 to 12, and a day valid for that month. February has 29 days in leap years (years divisible by 4, except century years not divisible by 400).string: anything else.Return an array with the type label of each field, in order.
Input: fields = ["1", "true", "12/05/2026", "sojdnvjbs", "12/14/2027"]
Output: ["int", "bool", "date", "string", "string"]
Explanation: "12/05/2026" is the 12th of May. "12/14/2027" is not a date:
14 is not a valid month, so it falls through to string.
Input: fields = ["-42", "FALSE", "29/02/2024", "29/02/2025", "3/04/2026"]
Output: ["int", "bool", "date", "string", "string"]
Explanation: 2024 is a leap year, 2025 is not. "3/04/2026" does not match the
two-digit day shape.
fields.length ≤104fields[i].length ≤30fields[i] consist of English letters, digits, / and -Click "Run" to test with sample cases or "Submit" to run all tests.