Version Order

Software versions are often written with dots, like 1.0.3, and compared part by part from left to right. Given two strings version1 and version2, compare each part as an integer, ignoring leading zeros and treating missing parts as 0. Return -1 if the first version is smaller, 1 if it is larger, and 0 if they are equal.

Примеры

Ввод
"1.01", "1.001"
Вывод
0
Ввод
"1.0", "1.0.0"
Вывод
0
Ввод
"0.1", "1.1"
Вывод
-1

Нужно реализовать

def compare_version(version1, version2):

Теги

stringstwo-pointersarray
PostgreSQLv16

Εδώ θα εμφανιστεί το αποτέλεσμα εκτέλεσης του κώδικα

Visible tests
1
Input
"1.01", "1.001"
Expected0
2
Input
"1.0", "1.0.0"
Expected0
3
Input
"0.1", "1.1"
Expected-1
4
Input
"1.2", "1.10"
Expected-1
5
Input
"7.5.2.4", "7.5.3"
Expected-1
6
Input
"1.0.0", "1"
Expected0
Focus radio
Paused · SomaFM · Fluid