题目链接:3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
*Elements in a triplet (a...
分类:
其他好文 时间:
2015-01-29 21:11:51
阅读次数:
180
原题地址双指针法。右指针不断向右试探,当遇到重复字符时停下来,此时左指针开始向右收缩,直到去掉那个重复字符。代码: 1 int lengthOfLongestSubstring(string s) { 2 map record; 3 int maxLen = 0; 4...
分类:
其他好文 时间:
2015-01-29 19:20:25
阅读次数:
140
题目链接:Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is ...
分类:
其他好文 时间:
2015-01-29 12:48:22
阅读次数:
226
原创作品,转载请标明出处http://blog.csdn.net/yming0221/article/details/7220688C语言更多查看C语言使用注意事项(一)C语言使用注意事项(二)C语言使用注意事项(三)二级指针又叫双指针。C语言中不存在引用,所以当你试图改变一个指针的值的时候必须使用...
分类:
编程语言 时间:
2015-01-29 11:51:22
阅读次数:
156
题目链接:Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters...
分类:
其他好文 时间:
2015-01-27 23:33:44
阅读次数:
176
Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).
For example,
S = "ADOBECODEBANC"
T = "ABC"
Minimum window is "BAN...
Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked lists:
A: a1 → a2
↘
...
分类:
其他好文 时间:
2015-01-16 11:18:52
阅读次数:
110
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ...
分类:
其他好文 时间:
2015-01-15 11:01:23
阅读次数:
186
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
Follow up:
Can you solve it without using extra space?
/**
* Definition for singly-linked list.
*...
分类:
其他好文 时间:
2015-01-15 11:01:22
阅读次数:
236
一、 题目
给定一个单链表,删除倒数第n个节点,返回删除了的链表。
例如: 已知: 1->2->3->4->5, n = 2.
处理后:1->2->3->5.
试着遍历一次完成。
二、 分析
看到这道题我第一感觉就是双指针,因为要删除倒数第n个数,所以两个指针的间距也就是这个n,当右边的指针到达末尾处时,那么左指针的下一个指针就是要删除的节点。其实会有下面...
分类:
其他好文 时间:
2015-01-14 09:51:12
阅读次数:
155