摘要: 题目:给定一个字符串,返回其中不包含重复字符的最长子串长度。解法:维持两个指针,第一个指向子串开始,第二个负责遍历,当遍历到的字符出现在子串内时,应计算当前子串长度,并更新最长值;然后第一个指针更新为出现位置的下一个。代码: 1 class Solution { 2 public: 3 in... 阅读全文
posted @ 2014-06-01 16:48 阿杰的专栏 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 题目:找两个排序数组A[m]和B[n]的中位数,时间复杂度为O(log(m+n))。解法:更泛化的,可以找第k个数,然后返回k=(m+n)/2时的值。代码: 1 class Solution 2 { 3 public: 4 double findMedianSortedArrays(int ... 阅读全文
posted @ 2014-06-01 15:16 阿杰的专栏 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 题目地址:https://oj.leetcode.com/problems/two-sum/Two SumGiven an array of integers, find two numbers such that they add up to a specific target number.Th... 阅读全文
posted @ 2014-06-01 14:19 阿杰的专栏 阅读(474) 评论(0) 推荐(0) 编辑