#-*- 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的更多相关文章

  1. 【LeetCode】165. Compare Version Numbers 解题报告(Python)

    [LeetCode]165. Compare Version Numbers 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博 ...

  2. 【刷题-LeetCode】165 Compare Version Numbers

    Compare Version Numbers Compare two version numbers version1 and version2. If *version1* > *versi ...

  3. 【一天一道LeetCode】#165. Compare Version Numbers

    一天一道LeetCode 本系列文章已全部上传至我的github,地址:ZeeCoder's Github 欢迎大家关注我的新浪微博,我的新浪微博 欢迎转载,转载请注明出处 (一)题目 来源: htt ...

  4. 【LeetCode】165 - Compare Version Numbers

    Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 &l ...

  5. 165. Compare Version Numbers - LeetCode

    Question 165. Compare Version Numbers Solution 题目大意: 比较版本号大小 思路: 根据逗号将版本号字符串转成数组,再比较每个数的大小 Java实现: p ...

  6. [LeetCode] 165. Compare Version Numbers 比较版本数

    Compare two version numbers version1 and version1.If version1 > version2 return 1, if version1 &l ...

  7. ✡ leetcode 165. Compare Version Numbers 比较两个字符串数字的大小 --------- java

    Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 &l ...

  8. Java for LeetCode 165 Compare Version Numbers

    Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 &l ...

  9. Java [Leetcode 165]Compare Version Numbers

    题目描述: Compare two version numbers version1 and version2.If version1 > version2 return 1, if versi ...

随机推荐

  1. LeetCode Find the Celebrity

    原题链接在这里:https://leetcode.com/problems/find-the-celebrity/ 题目: Suppose you are at a party with n peop ...

  2. 你知道吗?使用任何HTML5开发工具都可开发iOS、Android原生App

    APICloud App开发平台一直在不断升级开发工具库,这一年增加了众多开发工具.目的就是让开发者可以选择使用任何自己喜欢的HTML5开发工具去开发App.这次,APICloud把所有关于开发工具的 ...

  3. 解决Chrome flash过期

    解决Chrome flash过期的办法安装Adobe Flash Player PPAPI

  4. [Python] 删除指定目录下后缀为 xxx 的过期文件

    import os import time import datetime def should_remove(path, pattern, days): if not path.endswith(p ...

  5. php json 格式化

    header('content-type:application/json;charset=utf8'); $arr = array( 'status' => true, 'errMsg' =& ...

  6. Android 广播 BroadcastReceiver

    Android 系统里定义了各种各样的广播,如电池的使用状态,电话的接收和短信的接收,开机启动都会产生一个广播.当然用户也可以自定义自己的广播. 既然说到广播,那么必定有一个广播发送者,以及广播接收器 ...

  7. nginx跨域配置

    假设前端页面的地址为: 192.168.1.1/arcgis40/index.html 页面物理路径为: X:\nginx-1.9.15\html\arcgis40 那么请求服务时,当ajax代码如下 ...

  8. html5,视频的兼容

    <video controls="controls" width="500" >        <source src="1.mp4 ...

  9. cherrypy应用探究

    1. cherrypy是什么? cheerypy是一个有pythonic特性的面向对象的http服务框架. 玩python的人都应该知道pythonic这个单词.python大神给我们的建议 : &g ...

  10. Used Query

    ---  查询 look back 6 days logic period_key. select s.store_id, i.upc, sf.period_key from JNJ_CASINO_H ...