上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 37 下一页

2017年12月12日

Leetcode:445. Add Two Numbers II

摘要: 这题可以结合着前面几个博客的思想来解决,当然网上给出了更好的解决方案值得学习 我自己实现的代码,因为对java指针的使用不太熟悉,调试了一个小时。思路:先将l1,l2存放到字符串中(因为字符串的长度不受限制,而数组的长度会受到限制),然后从数组的最后一位开始计算 网上的代码:https://disc 阅读全文

posted @ 2017-12-12 21:24 Michael2397 阅读(228) 评论(0) 推荐(0) 编辑

Leetcode: 43. Multiply Strings

摘要: 题目难度中等,想到分别遍历num1、num2中的数值,但是具体细节没有理清。参考:https://discuss.leetcode.com/topic/30508/easiest-java-solution-with-graph-explanation?page=1 阅读全文

posted @ 2017-12-12 19:34 Michael2397 阅读(130) 评论(0) 推荐(0) 编辑

Leetcode:415. Add Strings

摘要: 结合着这篇http://www.cnblogs.com/Michael2397/p/8027782.html自己完全实现了,顿时感觉到刷题有套路啊 阅读全文

posted @ 2017-12-12 15:34 Michael2397 阅读(122) 评论(0) 推荐(0) 编辑

Leetcode: 371. Sum of Two Integers

摘要: 这一题要用到|,&,<<等运算,完全参考https://discuss.leetcode.com/topic/49764/0ms-ac-java-solution/2算是当作学习了 阅读全文

posted @ 2017-12-12 15:32 Michael2397 阅读(145) 评论(0) 推荐(0) 编辑

Leetcode: 67. Add Binary

摘要: 二进制加法 https://discuss.leetcode.com/topic/33693/another-simple-java 阅读全文

posted @ 2017-12-12 14:53 Michael2397 阅读(124) 评论(0) 推荐(0) 编辑

2017年12月11日

Leetcode: 2. Add Two Numbers

摘要: 一直想用一个进位变量来存贮进位值,但老是考虑不周全,下面是我自己写的bug代码,考虑不周,因为l1或者l2都有可能为null acccpt:https://discuss.leetcode.com/topic/799/is-this-algorithm-optimal-or-what 阅读全文

posted @ 2017-12-11 21:15 Michael2397 阅读(124) 评论(0) 推荐(0) 编辑

Leetcode:560. Subarray Sum Equals K

摘要: 最简单的方式,虽然oj没有说超时,但是时间还是挺多的 本次的方法是遍历所有起点是最开始元素的子序列,我们起名叫sum[i],只要两个sum[i]的差值是k,则两个i作为起点和终点的子序列就符合要求。由于起点就是最开始元素,只需遍历终点,时间复杂度为O(n)。 阅读全文

posted @ 2017-12-11 20:13 Michael2397 阅读(139) 评论(0) 推荐(0) 编辑

Leetcode: 653. Two Sum IV - Input is a BST

摘要: 超时代码:只多了一个bool变量就超时了 accpt的代码,把二叉树前序遍历得到list,顺序是从小到大排列的 阅读全文

posted @ 2017-12-11 09:48 Michael2397 阅读(126) 评论(0) 推荐(0) 编辑

Leetcode: 167. Two Sum II - Input array is sorted

摘要: 超时的代码: Accept代码:如果数组已经排好序了,就尽可能的使用while(),左右遍历 阅读全文

posted @ 2017-12-11 09:14 Michael2397 阅读(98) 评论(0) 推荐(0) 编辑

Leetcode:454. 4Sum II

摘要: 参考:https://discuss.leetcode.com/topic/67658/simple-java-solution-with-explanation 阅读全文

posted @ 2017-12-11 08:59 Michael2397 阅读(102) 评论(0) 推荐(0) 编辑

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 37 下一页

导航