![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
文章平均质量分 59
notail_woo
不积跬步无以至千里
展开
-
LeetCode: Reverse Integer (JavaScript)
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321本地测试通过,代码如下:var reverse = function(x) { var res = 0; while(x){ res = res*10 +x%10原创 2015-04-23 20:41:39 · 1360 阅读 · 0 评论 -
LeetCode: Tow Sum (JavaScript)
刚开始用indexOf的方法,若target - nums[i]存在于nums中,找到它们的下标并加1在本地测试通过,但是在leetcode上运行超时。代码如下:var twoSum = function(nums, target) { var tmp = []; var len = nums.length; for(var i=0; i<len; i++){原创 2015-04-23 20:12:15 · 627 阅读 · 0 评论 -
LeetCode Add Binary (JavaScript)
题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".思路:反序遍历字符串,并判断是否有进位。代码如下var addBinary = function(a, b) {原创 2015-04-27 15:23:33 · 686 阅读 · 0 评论 -
LeetCode Valid Parentheses (JavaScript)
Valid ParenthesesGiven a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" an原创 2015-04-28 09:23:21 · 970 阅读 · 0 评论