- 博客(144)
- 资源 (1)
- 收藏
- 关注
转载 海量数据处理系列----C++中Bitmap算法的实现
bitmap是一个十分有用的结构。所谓的Bit-map就是用一个bit位来标记某个元素对应的Value, 而Key即是该元素。由于采用了Bit为单位来存储数据,因此在存储空间方面,可以大大节省。 适用范围:可进行数据的快速查找,判重,删除,一般来说数据范围是int的10倍以下基本原理及要点:使用bit数组来表示某些元素是否存在,比如8位电话号码扩展:bloom fi
2013-11-08 13:38:56
1038
4
转载 KMP算法
转自:http://www.cnblogs.com/dolphin0520/archive/2011/08/24/2151846.html在介绍KMP算法之前,先介绍一下BF算法。一.BF算法BF算法是普通的模式匹配算法,BF算法的思想就是将目标串S的第一个字符与模式串P的第一个字符进行匹配,若相等,则继续比较S的第二个字符和P的第二个字符;若不相等,则比较S的第二个字符和P的第一
2013-09-21 17:36:41
658
原创 leetcode之Reverse Linked List II
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: Lis
2013-09-18 11:27:16
686
转载 leetcode之Roman to Integer
转自:http://blog.youkuaiyun.com/wyc1230/article/details/7263055Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.[cpp] view plaincop
2013-09-18 10:17:50
654
转载 leetcode之Rotate Image
转自:http://www.cnblogs.com/graph/archive/2013/07/31/3229056.htmlYou are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:
2013-09-18 09:47:29
886
原创 leetcode之Rotate List
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: Li
2013-09-18 08:59:43
653
原创 leetcode之Remove Element
class Solution {public: int removeElement(int A[], int n, int elem) { // Start typing your C/C++ solution below // DO NOT write int main() function if (A==NULL||n
2013-09-17 23:03:10
571
原创 leetcode之Remove Nth Node From End of List
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: Li
2013-09-17 22:52:29
598
原创 leetcode之Remove Duplicates from Sorted List II
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: Lis
2013-09-17 21:33:20
705
原创 leetcode之Remove Duplicates from Sorted List II
class Solution {public: int removeDuplicates(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function if(A==NULL||n
2013-09-17 21:01:29
617
原创 leetcode之Remove Duplicates from Sorted Array
class Solution {public: int removeDuplicates(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function if (A==NULL || n
2013-09-17 20:47:05
742
原创 leetcode之Remove Duplicates from Sorted List
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: Li
2013-09-17 20:12:20
666
转载 等概率随机函数面试题总结
目录(?)[-]随机数范围扩展方法总结httpwwwcppblogcommyjfmarchive20120910190092htmlhttpblogcsdnnethackbuteer1articledetails7486704等概率随机函数面试题总结 在面试中也常考等概率随机函数的题目,所以很重要,特此整理下,资料全来自网上。1. 几道热
2013-09-17 16:42:47
1589
转载 一般函数指针和类的成员函数指针
转载请注明原文网址: http://www.cnblogs.com/xianyunhe/archive/2011/11/26/2264709.html函数指针是通过指向函数的指针间接调用函数。函数指针可以实现对参数类型、参数顺序、返回值都相同的函数进行封装,是多态的一种实现方式。由于类的非静态成员函数中有一个隐形的this指针,因此,类的成员函数的指针和一般函数的指针的表现形式不一样。
2013-09-15 12:00:22
460
原创 leetcode之Swap Nodes in Pairs
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: Li
2013-09-14 23:14:57
716
转载 leetcode之Spiral Matrix
转自:http://blog.youkuaiyun.com/martin_liang/article/details/8982562Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the
2013-09-14 21:57:55
614
原创 leetcode之Search for a Range
class Solution {public: int bsearch(int A[], int beg, int end, int target) { if (beg>end) { return -1; } int mid = (beg+end)/2; if (A[mid]==targ
2013-09-14 20:55:43
739
原创 leetcode之Search a 2D Matrix
class Solution {public: bool searchMatrix(vector > &matrix, int target) { // Start typing your C/C++ solution below // DO NOT write int main() function int m = matrix
2013-09-14 20:34:57
559
原创 leetcode之Search Insert Position
class Solution {public: int core(int A[], int beg, int end, int target) { if (beg==end && A[beg] return beg+1; } if (beg==end&&A[beg]>target) {
2013-09-14 10:19:15
595
原创 leetcode之Valid Parentheses
class Solution {public: bool isValid(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function int n = s.size(); if (n==0) {
2013-09-13 18:44:27
511
原创 leetcode之Longest Palindromic Substring
泪奔了,改了一个边界条件就华丽丽的通过了~在这之前,做了好多无用功,只想说一句,叉~class Solution {public: string longestPalindrome(string s) { // Start typing your C/C++ solution below // DO NOT write int main() fu
2013-09-09 18:40:19
539
转载 leetcode之Interleaving String
转自:http://blog.unieagle.net/2012/09/29/leetcode%E9%A2%98%E7%9B%AE%EF%BC%9Ainterleaving-string%EF%BC%8C%E4%BA%8C%E7%BB%B4%E5%8A%A8%E6%80%81%E8%A7%84%E5%88%92/LeetCode题目:Interleaving String,二维
2013-09-09 17:40:07
934
原创 leetcode之Longest Substring Without Repeating Characters
class Solution {private: bool canUse[256];public: int lengthOfLongestSubstring(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function
2013-09-09 16:06:04
578
转载 Leetcode 4 Median of Two Sorted Arrays
转载:http://blog.youkuaiyun.com/zxzxy1988/article/details/8587244今天发现了leetcode上面一道题,觉得非常经典,记录之。题目是这样的:给定两个已经排序好的数组(可能为空),找到两者所有元素中第k大的元素。另外一种更加具体的形式是,找到所有元素的中位数。本篇文章我们只讨论更加一般性的问题:如何找到两个数组中第k大的元素?不过,
2013-09-09 14:05:06
612
原创 leetcode之Two Sum
class Solution {public: vector twoSum(vector &numbers, int target) { // Start typing your C/C++ solution below // DO NOT write int main() function vector res;
2013-09-09 12:31:31
488
原创 leetcode之Pascal's Triangle II
class Solution {public: vector getRow(int rowIndex) { // Start typing your C/C++ solution below // DO NOT write int main() function vector res; res.push_
2013-09-09 11:05:58
543
原创 leetcode之Pascal's Triangle
class Solution {public: vector > generate(int numRows) { // Start typing your C/C++ solution below // DO NOT write int main() function vector > res; i
2013-09-09 10:53:49
595
原创 leetcode之Gray code
class Solution {public: vector grayCode(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function int size = 1 vector res;
2013-09-08 21:55:09
593
原创 leetcode之Edit Distance
class Solution {public: int minDistance(string word1, string word2) { // Start typing your C/C++ solution below // DO NOT write int main() function int len1 = word1.s
2013-09-08 21:37:09
658
原创 leetcode之Valid Palindrome
class Solution {public: bool isPalindrome(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function if (s.empty()) { retu
2013-09-08 19:23:04
570
原创 leetcode之Sum Root to Leaf Numbers
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */cla
2013-09-08 17:13:01
667
转载 [Leetcode]Palindrome Partitioning II
转载:http://blog.youkuaiyun.com/u010970771/article/details/9126437思路:动态规划步骤:1、计算字符串所有字串是否是回文(可以避免后面计算时重复的判断是否是回文)状态方程:2、DP计算最小分割数状态方程:[cpp] view plaincopyclass Solution
2013-09-08 15:55:09
604
原创 leetcode之Palindrome Partitioning
class Solution {public: bool isPal(string s) { if (s.size() return true; } int beg=0; int end=s.size()-1; while (beg if(s[
2013-09-08 15:15:42
524
原创 leetcode之Plus One
class Solution {public: vector plusOne(vector &digits) { // Start typing your C/C++ solution below // DO NOT write int main() function if (digits.empty()) {
2013-09-08 12:25:49
557
原创 leetcode之same tree
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */cla
2013-09-08 11:44:45
648
原创 leetcode之Path Sum II
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */cla
2013-09-08 11:37:14
534
原创 leetcode之Path Sum
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */cla
2013-09-08 11:21:55
636
原创 leetcode之subsets
#include #include using namespace std;void dfs(int depth, vector& s, vector >& res, vector a, int start) { res.push_back(a); if (depth == s.size()) return; for (int i = sta
2013-09-07 20:00:03
630
原创 leetcode之Reverse Linked List II
#include #include struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {} }; ListNode *reverseBetween(ListNode *head, int m, int n) {
2013-09-07 19:12:24
601
原创 leetcode之Reverse Integer
class Solution {public: int reverse(int x) { // Start typing your C/C++ solution below // DO NOT write int main() function char nums[11]; memset(nums, 11, 0)
2013-09-07 18:14:44
545
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人