As reported: ServiceNow Staff Software Engineer (full stack) technical interview (1 hour), Dec 2025: a topological-sort problem, SQL questions on joins, a frontend question on drag-and-drop events, and implementing semantic version validation, where time ran out.
Implement isValidSemver(version), which returns whether version is a valid version under Semantic Versioning 2.0.0:
- Core:
MAJOR.MINOR.PATCH— exactly three numeric identifiers separated by dots. - Numeric identifier: one or more digits
0–9, with no leading zero unless the identifier is exactly0. - Pre-release (optional): a
-after the core, then one or more dot-separated identifiers. Each is non-empty and uses only0–9,A–Z,a–zand-; an identifier made only of digits must not have a leading zero. - Build metadata (optional): a
+after the core or the pre-release, then one or more dot-separated non-empty identifiers of0–9,A–Z,a–z,-(leading zeros allowed). - Nothing else: no
vprefix, no spaces, no empty identifiers.
Example
"1.0.0" -> true
"1.0.0-alpha.1" -> true
"1.0.0-beta+exp.sha.5114f85" -> true
"1.0.0+001" -> true (leading zeros are fine in build metadata)
"01.0.0" -> false (leading zero)
"1.0" -> false (only two parts)
"1.0.0-" -> false (empty pre-release)
"1.0.0-01" -> false (numeric pre-release identifier with a leading zero)
Constraints: 0 ≤ version.length ≤ 200; numbers may be longer than 64 bits (validate the text, do not parse to an integer).
Code runner format: one line with a JSON array of version strings. Implement isValidSemver(version); the harness calls it for each string and prints the array of results.
Clarifications
- The first
+starts the build metadata; within what is left, the first-starts the pre-release (the core cannot contain-, while pre-release identifiers can).