【leetcode❤python】 165. Compare Version Numbers
#-*- coding: UTF-8 -*-
class Solution(object):
def compareVersion(self, version1, version2):
"""
:type version1: str
:type version2: str
:rtype: int
"""
versionl1=version1.split('.')
versionl2=version2.split('.')
n1,n2=len(versionl1),len(versionl2)
if n1>n2:
versionl2+=[0]*(n1-n2)
else:versionl1+=[0]*(n2-n1)
for i in range(len(versionl1)):
if int(versionl1[i])>int(versionl2[i]):return 1
elif int(versionl1[i])<int(versionl2[i]):return -1
return 0
sol=Solution()
print sol.compareVersion('1', '1.1')
【leetcode❤python】 165. Compare Version Numbers的更多相关文章
- 【LeetCode】165. Compare Version Numbers 解题报告(Python)
[LeetCode]165. Compare Version Numbers 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博 ...
- 【刷题-LeetCode】165 Compare Version Numbers
Compare Version Numbers Compare two version numbers version1 and version2. If *version1* > *versi ...
- 【一天一道LeetCode】#165. Compare Version Numbers
一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 来源: htt ...
- 【LeetCode】165 - Compare Version Numbers
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 &l ...
- 165. Compare Version Numbers - LeetCode
Question 165. Compare Version Numbers Solution 题目大意: 比较版本号大小 思路: 根据逗号将版本号字符串转成数组,再比较每个数的大小 Java实现: p ...
- [LeetCode] 165. Compare Version Numbers 比较版本数
Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 &l ...
- ✡ leetcode 165. Compare Version Numbers 比较两个字符串数字的大小 --------- java
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 &l ...
- Java for LeetCode 165 Compare Version Numbers
Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 &l ...
- Java [Leetcode 165]Compare Version Numbers
题目描述: Compare two version numbers version1 and version2.If version1 > version2 return 1, if versi ...
随机推荐
- vim - line
copy complete current line: yy replace a char (e.g. comma) to new line: %s/,/\r/g
- mac常用的命令
1.递归查找⽂文件内容: grep -r target_string absolute_path 2.移动所有⽂文件(包括隐藏⽂文件): mv * .[^.]* targetDir 3.⽂文件分割合并 ...
- App.domain http->https
App.domain = `${location.origin}/toa-mgw/rest/gateway`.replace(/http:\/\//, 'https://');
- Spark:Join相关优化文章
http://blog.csdn.net/lsshlsw/article/details/48975771 https://www.douban.com/note/499691663/ http:// ...
- TP框架主要文件夹注释
TP框架主要文件夹注释 common -> 函数库目录 conf -> 配置文件目录lang -> 语言包librang -> 核心资源库 behacior -> 行为目 ...
- vbs让电脑发音说话
Dim vbs1 'set vbs1 = WScript.CreateObject("WScript.Shell") set vbs1 = WScript.CreateObject ...
- CSS生成内容
在Web中插入内容,在CSS2.1时代依靠的是JavaScript来实现.但进入CSS3进代之后我们可以通过CSS3的伪类“:before”,“:after”和CSS3的伪元素“::before”.“ ...
- oracle 11g如何完全卸载
方法/步骤 停用oracle服务:进入计算机管理,在服务中,找到oracle开头的所有服务,右击选择停止 在开始菜单中,找到Universal Installer,运行Oracle Unive ...
- sql查询指定表外键约束
//////////////////查询指定表外键约束select a.name as 约束名, object_name(b.parent_object_id) as 外键表, d.name as 外 ...
- Visual Studio 2015 Update 3 正式版下载
vs2015-update3 .NET Core 1.0 文件名 cn_visual_studio_enterprise_2015_with_update_3_x86_x64_dvd_8923 ...