- 博客(4)
- 收藏
- 关注
原创 leetcode005:Add 2 numbers
Add Two Numbers You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers an
2012-12-11 23:12:06 800
原创 leetcode004:add binary
莫非深夜真的coder最有灵感的时候? 题目: /** * Given two binary strings, return their sum (also a binary string). * For example, * a = "11" * b = "1" * Return "100". * */思路: 1.当字符串有一个为空或者为0时,相当于答案取决于另一个
2012-12-07 00:43:45 620
原创 leetcode003:4 sum
嗯嗯,这次是4sum题了。 4Sum Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the s
2012-12-03 23:51:55 496
原创 leetcode002:3sum closest
我去,时隔好几天才真的来解决第二个问题,太懒了,没怎么去思考。还是参考了下网上其他人的做法,才知道自己想的太复杂了,在判断指针左右移的时候纠结了。但其实算法跟第一题大致相同的,同样的思路解决o^2问题,再者就是如何去判断是否靠近了,这部分需要注意的应该就是判断的是绝对值而不是单纯相减.public class Solution { public int threeSumClosest(in
2012-12-02 20:30:52 706
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人