Skip to content

Commit cf01de0

Browse files
committed
3-5-24
1 parent b5409fb commit cf01de0

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

May-3-24.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class Solution:
2+
def compareVersion(self, version1: str, version2: str) -> int:
3+
i = 0
4+
v1 = list(map(int,version1.split('.')))
5+
v2 = list(map(int,version2.split('.')))
6+
if v1==v2:
7+
return 0
8+
while i<len(v1) and i<len(v2):
9+
if v1[i]==v2[i]:
10+
i += 1
11+
else:
12+
if v1[i]>v2[i]:
13+
return 1
14+
return -1
15+
while i<len(v1):
16+
if v1[i]>0:
17+
return 1
18+
i += 1
19+
while i<len(v2):
20+
if v2[i]>0:
21+
return -1
22+
i += 1
23+
return 0

0 commit comments

Comments
 (0)