单链表的实现思想和双指针的应用方法在前面博客中都已阐述,在本文将实现双指针实现单链表的初始化,插入,删除,打印。
【测试代码1】#include
#includetypedef struct Node{
int data;
struct Node *next;
}node_t;//创建头结点
node_t * create()
{
n...
分类:
其他好文 时间:
2015-05-20 20:40:38
阅读次数:
116
链接:
#include
int main()
{
puts("转载请注明出处[vmurder]谢谢");
puts("网址:blog.csdn.net/vmurder/article/details/43407071");
}
题解:
三个定义:高度h,v速度,Ah+Bv为s
首先我们在外圈枚举来固定其中一个权值,姑且枚举v吧。每次枚举值大写为V。
然后在内圈就可...
分类:
其他好文 时间:
2015-05-15 17:50:57
阅读次数:
211
1071: [SCOI2007]组队Time Limit:1 SecMemory Limit:162 MBSubmit:1267Solved:392[Submit][Status][Discuss]DescriptionNBA每年都有球员选秀环节。通常用速度和身高两项数据来衡量一个篮球运动员的基本素...
分类:
其他好文 时间:
2015-05-15 17:33:05
阅读次数:
156
给定一个字符串,找到最多有k个不同字符的最长子字符串。
样例
例如,给定 s = "eceba" , k
= 3,
T 是 "eceb",长度为 4.
挑战
O(n), n 是所给字符串的长度
分析:采用双指针,用map记录双指针中间的字符串是否满足要求
代码:
class Solution {
public:
/**
* @param...
分类:
其他好文 时间:
2015-05-14 20:35:49
阅读次数:
654
problem:
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
Hide Tags
Linked List Two
Pointers
...
分类:
其他好文 时间:
2015-05-04 12:05:09
阅读次数:
148
problem:
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?
Hide Tags
Linked Lis...
分类:
其他好文 时间:
2015-05-04 11:58:22
阅读次数:
133
一个n边形的面积,可以三角剖分成n 个每个边和原点构成的三角形的有向面积
这样每条边等于一个有向面积,那么问题转化成只要求每条边能作为几个凸包的边
那么枚举一点O,这样对于任意一点X会有一条OX的边,而这条边构成凸包的数量,显然就是只能在和他夹角180度以内的边以内找,也就是有多少个点,就是2^num - 1(因为至少要有一个点)
于是进行极角排序,双指针扫一遍就能得到所有答案
代码:
...
分类:
其他好文 时间:
2015-04-29 13:35:23
阅读次数:
122
Given an array and a value, remove all instances of that value in place and return the new length.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
时间复...
分类:
其他好文 时间:
2015-04-23 09:43:01
阅读次数:
196
问题描述:
问题分析:
解法一:设置双指针,start,end;当data[start]=‘1’,data[end]=’0’时,表示需要进行交换,次数加1;否则data[end]=’1’则前移end指针;data[start]=‘0’则后移start指针;
该算法仅需遍历一次
解法二:先遍历一次计算字符数组中0的个数zero,再计算前zero个字符中1的个数,即是要交换到后面的...
分类:
编程语言 时间:
2015-04-20 14:53:39
阅读次数:
110
leetcode中有几个求sum的问题,思路基本上一样,在这里一并列出。这几道题主要思路是在使用双指针解决2SUM的基础上,将kSUM逐步reduce到2SUM。 大致框架如下:1) sort2) repeatedly reduce kSUM to k-1SUM, until 2SUM3) solv...
分类:
其他好文 时间:
2015-04-18 01:07:09
阅读次数:
216