- 博客(170)
- 资源 (7)
- 收藏
- 关注
![](https://csdnimg.cn/release/blogv2/dist/pc/img/listFixedTop.png)
原创 leetcode 目录--更新....
//注:很多代码未加入,内存分配是否成功的判断!//二维数组分配问题需注意,leetcode 可以接受变量的a[m][n],自己实现需,int **a = new int [m];for(){a[i] = new int[n]} -- 释放类似1、String to Integer (atoi)2、 Populating Next Right Pointers in Each Nod...
2013-11-24 19:23:44
1944
原创 Sort Colors
Sort ColorsGiven an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we w...
2018-08-24 10:13:03
196
转载 多个正则引擎的比较(pcre re2 hyperscan)
A comparison of regex engines (多个正则引擎的比较) https://rust-leipzig.github.io/regex/2017/03/28/comparison-of-regex-engines/
2017-05-04 18:39:15
6366
原创 解析URL
简介在github有轮子http-parser解析器,小的就不再造轮子了,哈哈(造这个轮子真不是一时半会的事)。目前该解析器用于nodejs的http解析,另还有大家熟知的tcpflow 以及 libtnet都以他作为引擎。 http-parser地址:http-parserhttp-parser是一个用C代码编写的HTTP消息解析器。可以解析HTTP请求或者回应消息。 这个解析器常常在高性能的H
2016-08-18 17:35:45
2783
转载 Netfilter的使用和实现
本文主要内容:Netfilter的原理和实现浅析,以及示例模块。内核版本:2.6.37Author:zhangskd @ csdn blog原文章地址: http://blog.csdn.net/zhangskd/article/details/22678659概述 Netfilter为多种网络协议(IPv4、IPv6、ARP等)各提供了一套
2016-08-02 09:16:33
1806
原创 柔性数组
柔性数组数组大小待定的数组(可变)C语言中结构体的最后一个元素可以是大小可变的数组 (只能放在结构体中,表明一种符号)C语言中可以由结构体产生柔性数组int size[0]这种在C/C++是不允许的,但是在结构中确实可以使用的(C99标准)。经过查看资料,知道这种可变数组被称为柔性数组。在通信行业这种代码司空见惯。柔性数组的结构如何只能堆上生成,C99的扩展,简而言之就是一个在struct结
2016-08-01 11:56:11
408
转载 类似无穷期望概率题
首先介绍:两个人抛硬币来决定谁吃这个苹果,先抛到正面者吃。问先抛者吃到苹果的概率是多少?此种,先假设某种情况,需要P,zaig
2014-09-01 11:05:24
2335
转载 C++中 overload 、override、overwrite 之间的区别
转自:http://blog.csdn.net/jszhangyili/article/details/7570311gerOverload、Overwrite和Override的概念比较容易混淆,而且Overwrite和Override的中文翻译五花八门,让人很Confuse,顾保持英文原意:Overload 重载在C++程序中,可以将语义、功能相似的几个函数用
2014-08-19 22:09:08
746
转载 Linux环境进程间通信(二): 信号
原文来自: http://www.ibm.com/developerworks/cn/linux/l-ipc/part2/index1.html#icomments
2014-08-14 22:24:31
638
原创 cron调度问题
cron是一个后台调度程序。该进程一分钟检查一次,并读取crontab文件进行执行。使用crontab -e生成的文件在/var/spool/cron/crontabs 下根据相应的用户名命名。在用的时候碰到一问题,按正常的步骤 crontab -e 编辑* * * * * /bin/echo "hello" 写入后发现并没有反应,后来查到需要安装邮件系统类东西。但是我想找具体原
2014-08-08 20:42:29
755
原创 两个人抛硬币来决定谁吃这个苹果,先抛到正面者吃。问先抛者吃到苹果的概率是多少?
A和B2人投硬币,正面A得1元,反面B得一元.起始时A有1元,B有100元. 游戏持续进行,直到其中1人破产才终止.1.如果硬币正反概率相同,游戏的期待长度(expected duration)是几次投掷? 2.如果硬币是不公正的,正面概率为P,反面概率为Q.(P+Q=1), 那么游戏的期待长度(expectedduration)是几次投掷?目前认为只有奇数次才可能破产。
2014-07-31 22:39:51
21813
2
原创 Remove Element
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.一
2014-07-24 10:55:46
533
原创 Sort Colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Here, we will use the integers
2014-07-10 17:16:32
561
原创 Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is
2014-07-10 10:46:12
531
原创 Simplify Path
Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner Cases:Did
2014-07-09 22:59:14
514
原创 Anagrams
Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.此题已处理的了,回文。首先
2014-07-09 17:34:37
549
原创 Count and Say
The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 is read off as
2014-07-09 16:36:37
587
原创 数字转中文表示
此处表达式b#include #include #include using namespace std;string int_to_num(int num);int main(){ int num; cin>>num; cout<<int_to_num(num)<<endl; return 0;}string int_to_num(int num)
2014-07-09 11:36:40
667
原创 Longest Palindromic Substring
#include #include #include using namespace std;string longestPalindrome(string s) ;int main(){ string s; cin>>s; cout<<longestPalindrome(s)<<endl; return 0;}string longestPalindrome
2014-07-08 11:15:57
953
原创 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 sum of target.Note:Element
2014-07-07 21:54:03
522
原创 3Sum Closest
Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would have exact
2014-07-07 10:59:42
581
原创 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,b,c
2014-07-07 10:11:10
545
原创 Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S.A subsequence of a string is a new string which is formed from the original string by deleting some (can be non
2014-07-04 16:38:41
545
原创 Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total nu
2014-07-04 15:07:32
485
原创 Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:
2014-07-03 20:39:17
611
原创 Largest Rectangle in Histogram -- 待看
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.Above is a histogram where width o
2014-07-03 15:25:35
516
原创 Triangle
Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3,4], [
2014-07-02 15:50:23
955
原创 Search a 2D Matrix
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to right.The first integer of each
2014-07-02 11:19:01
545
原创 Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array.
2014-07-02 10:53:20
507
原创 Search for a Range
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found
2014-07-02 10:32:21
493
原创 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 at (i, ai) and (i, 0). Fin
2014-07-01 16:36:08
517
原创 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 for "abcabcbb" is "abc", which the length is 3. Fo
2014-07-01 15:46:20
478
原创 Best Time to Buy and Sell Stock III
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.此题看清题,最多俩次jiaoy
2014-06-30 21:27:19
516
原创 Best Time to Buy and Sell Stock II
Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy on
2014-06-30 21:13:56
487
原创 Best Time to Buy and Sell Stock
Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),
2014-06-30 21:06:50
544
原创 Jump Game II
//dp 问题 ,dp[i] = min(dp[j])+1;(0 i的情况(即能覆盖i) ) //dp[i] 为0-i的的最少步数 int jump_game(int *a,int n) { if (a == NULL || n <= 0) { return 0; } int *count = new int [n];
2014-06-30 17:16:39
505
原创 Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine i
2014-06-30 17:05:14
519
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人