Code RoomCompare version strings
EasyPrep Room Coding #1382

Compare version strings

CodingAlgorithms & data structuresEntry–Mid~18 min

Compare two dot-separated version strings a and b, where each chunk is a non-negative integer (no leading-zero significance: '1.01' equals '1.1'). Return -1 if a < b, 1 if a > b, and 0 if equal. Missing trailing chunks are treated as 0, so '1.0' equals '1'. Each version has up to a few hundred chunks.

Implement
compare_versions(a: str, b: str) → int
Examples
in["1.2","1.10"]out-1
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 18 min
InputExpectedGot
["1.2","1.10"]-1not run yetsample