payload: {"action":"created","issue":{"url":"https://api.github.com/repos/azl397985856/leetcode/issues/174","repository_url":"https://api.github.com/repos/azl397985856/leetcode","labels_url":"https://api.github.com/repos/azl397985856/leetcode/issues/174/labels{/name}","comments_url":"https://api.github.com/repos/azl397985856/leetcode/issues/174/comments","events_url":"https://api.github.com/repos/azl397985856/leetcode/issues/174/events","html_url":"https://github.com/azl397985856/leetcode/issues/174","id":493816688,"node_id":"MDU6SXNzdWU0OTM4MTY2ODg=","number":174,"title":"【每日一题】- 2019-09-16 - 165. 比较版本号","user":{"login":"azl397985856","id":12479470,"node_id":"MDQ6VXNlcjEyNDc5NDcw","avatar_url":"https://avatars1.githubusercontent.com/u/12479470?v=4","gravatar_id":"","url":"https://api.github.com/users/azl397985856","html_url":"https://github.com/azl397985856","followers_url":"https://api.github.com/users/azl397985856/followers","following_url":"https://api.github.com/users/azl397985856/following{/other_user}","gists_url":"https://api.github.com/users/azl397985856/gists{/gist_id}","starred_url":"https://api.github.com/users/azl397985856/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/azl397985856/subscriptions","organizations_url":"https://api.github.com/users/azl397985856/orgs","repos_url":"https://api.github.com/users/azl397985856/repos","events_url":"https://api.github.com/users/azl397985856/events{/privacy}","received_events_url":"https://api.github.com/users/azl397985856/received_events","type":"User","site_admin":false},"labels":[{"id":1484322955,"node_id":"MDU6TGFiZWwxNDg0MzIyOTU1","url":"https://api.github.com/repos/azl397985856/leetcode/labels/Daily%20Question","name":"Daily Question","color":"49d898","default":false},{"id":1512792634,"node_id":"MDU6TGFiZWwxNTEyNzkyNjM0","url":"https://api.github.com/repos/azl397985856/leetcode/labels/Medium","name":"Medium","color":"ed4b1a","default":false},{"id":1523784263,"node_id":"MDU6TGFiZWwxNTIzNzg0MjYz","url":"https://api.github.com/repos/azl397985856/leetcode/labels/String","name":"String","color":"bfd4f2","default":false}],"state":"open","locked":false,"assignee":{"login":"lvguofeng1303","id":35688347,"node_id":"MDQ6VXNlcjM1Njg4MzQ3","avatar_url":"https://avatars3.githubusercontent.com/u/35688347?v=4","gravatar_id":"","url":"https://api.github.com/users/lvguofeng1303","html_url":"https://github.com/lvguofeng1303","followers_url":"https://api.github.com/users/lvguofeng1303/followers","following_url":"https://api.github.com/users/lvguofeng1303/following{/other_user}","gists_url":"https://api.github.com/users/lvguofeng1303/gists{/gist_id}","starred_url":"https://api.github.com/users/lvguofeng1303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lvguofeng1303/subscriptions","organizations_url":"https://api.github.com/users/lvguofeng1303/orgs","repos_url":"https://api.github.com/users/lvguofeng1303/repos","events_url":"https://api.github.com/users/lvguofeng1303/events{/privacy}","received_events_url":"https://api.github.com/users/lvguofeng1303/received_events","type":"User","site_admin":false},"assignees":[{"login":"lvguofeng1303","id":35688347,"node_id":"MDQ6VXNlcjM1Njg4MzQ3","avatar_url":"https://avatars3.githubusercontent.com/u/35688347?v=4","gravatar_id":"","url":"https://api.github.com/users/lvguofeng1303","html_url":"https://github.com/lvguofeng1303","followers_url":"https://api.github.com/users/lvguofeng1303/followers","following_url":"https://api.github.com/users/lvguofeng1303/following{/other_user}","gists_url":"https://api.github.com/users/lvguofeng1303/gists{/gist_id}","starred_url":"https://api.github.com/users/lvguofeng1303/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lvguofeng1303/subscriptions","organizations_url":"https://api.github.com/users/lvguofeng1303/orgs","repos_url":"https://api.github.com/users/lvguofeng1303/repos","events_url":"https://api.github.com/users/lvguofeng1303/events{/privacy}","received_events_url":"https://api.github.com/users/lvguofeng1303/received_events","type":"User","site_admin":false}],"milestone":null,"comments":2,"created_at":"2019-09-16T01:59:08Z","updated_at":"2019-09-16T08:53:20Z","closed_at":null,"author_association":"OWNER","body":"比较两个版本号 version1 和 version2。\r\n如果 version1 > version2 返回 1，如果 version1 < version2 返回 -1， 除此之外返回 0。\r\n\r\n你可以假设版本字符串非空，并且只包含数字和 . 字符。\r\n\r\n . 字符不代表小数点，而是用于分隔数字序列。\r\n\r\n例如，2.5 不是“两个半”，也不是“差一半到三”，而是第二版中的第五个小版本。\r\n\r\n你可以假设版本号的每一级的默认修订版号为 0。例如，版本号 3.4 的第一级（大版本）和第二级（小版本）修订号分别为 3 和 4。其第三级和第四级修订号均为 0。\r\n \r\n\r\n示例 1:\r\n\r\n输入: version1 = \"0.1\", version2 = \"1.1\"\r\n输出: -1\r\n示例 2:\r\n\r\n输入: version1 = \"1.0.1\", version2 = \"1\"\r\n输出: 1\r\n示例 3:\r\n\r\n输入: version1 = \"7.5.2.4\", version2 = \"7.5.3\"\r\n输出: -1\r\n示例 4：\r\n\r\n输入：version1 = \"1.01\", version2 = \"1.001\"\r\n输出：0\r\n解释：忽略前导零，“01” 和 “001” 表示相同的数字 “1”。\r\n示例 5：\r\n\r\n输入：version1 = \"1.0\", version2 = \"1.0.0\"\r\n输出：0\r\n解释：version1 没有第三级修订号，这意味着它的第三级修订号默认为 “0”。\r\n \r\n\r\n提示：\r\n\r\n版本字符串由以点 （.） 分隔的数字字符串组成。这个数字字符串可能有前导零。\r\n版本字符串不以点开始或结束，并且其中不会有两个连续的点。\r\n\r\n来源：力扣（LeetCode）\r\n链接：https://leetcode-cn.com/problems/compare-version-numbers\r\n著作权归领扣网络所有。商业转载请联系官方授权，非商业转载请注明出处。"},"comment":{"url":"https://api.github.com/repos/azl397985856/leetcode/issues/comments/531692448","html_url":"https://github.com/azl397985856/leetcode/issues/174#issuecomment-531692448","issue_url":"https://api.github.com/repos/azl397985856/leetcode/issues/174","id":531692448,"node_id":"MDEyOklzc3VlQ29tbWVudDUzMTY5MjQ0OA==","user":{"login":"xiongcaihu","id":10113078,"node_id":"MDQ6VXNlcjEwMTEzMDc4","avatar_url":"https://avatars0.githubusercontent.com/u/10113078?v=4","gravatar_id":"","url":"https://api.github.com/users/xiongcaihu","html_url":"https://github.com/xiongcaihu","followers_url":"https://api.github.com/users/xiongcaihu/followers","following_url":"https://api.github.com/users/xiongcaihu/following{/other_user}","gists_url":"https://api.github.com/users/xiongcaihu/gists{/gist_id}","starred_url":"https://api.github.com/users/xiongcaihu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xiongcaihu/subscriptions","organizations_url":"https://api.github.com/users/xiongcaihu/orgs","repos_url":"https://api.github.com/users/xiongcaihu/repos","events_url":"https://api.github.com/users/xiongcaihu/events{/privacy}","received_events_url":"https://api.github.com/users/xiongcaihu/received_events","type":"User","site_admin":false},"created_at":"2019-09-16T08:53:20Z","updated_at":"2019-09-16T08:53:20Z","author_association":"CONTRIBUTOR","body":"> 思路\r\n> 转换成数字，再进行比较\r\n由于版本号是这样的格式 *.*.*.*，且每一位都是0-9，或者是有前导0的组合，比如001，002，所以可以用一个四位数表示，去除前导0用parseInt即可。\r\n\r\n``` .js\r\n/**\r\n * @param {string} version1\r\n * @param {string} version2\r\n * @return {number}\r\n */\r\nvar compareVersion = function (version1, version2) {\r\n    var a = 0,\r\n        b = 0;\r\n    version1.split(\".\").forEach((item, index) => {\r\n        a += parseInt(item) * 10 ** (3 - index)\r\n    });\r\n\r\n    version2.split(\".\").forEach((item, index) => {\r\n        b += parseInt(item) * 10 ** (3 - index)\r\n    });\r\n\r\n    return a > b ? 1 : a == b ? 0 : -1;\r\n};\r\n```\r\n\r\n![image](https://user-images.githubusercontent.com/10113078/64945118-78882280-d8a2-11e9-9cde-805d00b53b29.png)\r\n"}}
other: {"actor":{"display_login":"xiongcaihu"}}