Medium
Quiz
#165 Compare Version Numbers
APPROACH
Compare two version strings version1 and version2. Each is a sequence of integer revisions separated by dots '.'; leading zeros within each revision are ignored.
Compare revision values left to right. Treat any missing revision as 0.
Return the following:
- -1 if version1 < version2.
- 1 if version1 > version2.
- 0 if they are equal.
1 of 4
1:00
What is the optimal approach for this problem?