- 博客(100)
- 资源 (27)
- 收藏
- 关注
原创 [LeetCode]Reverse Nodes in k-Group
struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {//once the link order of the list is changed, //we must keep the previous pointer(p in the c
2013-05-31 10:40:02 1633
原创 [LeetCode]Reverse Integer
class Solution {public: int reverse(int x) { // Start typing your C/C++ solution below // DO NOT write int main() function int sign = 1; if(x < 0) sign = -1; unsigned int num = x < 0 ? -x
2013-05-31 10:39:53 838
原创 [LeetCode]Remove Nth Node From End of List
struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode *removeNthFromEnd(ListNode *head, int n) { // Start typing your
2013-05-31 10:39:34 1374
原创 [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 int len = 0; for (int i = 0; i < n; ++i)
2013-05-31 10:39:31 1540 2
原创 [LeetCode]Remove Duplicates from Sorted List II
struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {//three pointer, the previous valid pointer, the first pointer of these same elements, curre
2013-05-31 10:39:27 1255
原创 [LeetCode]Remove Duplicates from Sorted List
struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {//just record the previous pointer, and the current pointerpublic: ListNode *deleteDuplica
2013-05-31 10:39:24 1124
原创 [LeetCode]Remove Duplicates from Sorted Array II
class Solution {//get the condition of copy or not copypublic: int removeDuplicates(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function int cur = 2
2013-05-31 10:39:20 2170
原创 [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(0 == n) return 0; int len = 1; for (int i =
2013-05-31 10:39:17 887
原创 [LeetCode]Regular Expression Matching
class Solution {//1. If the next character of p is NOT '*', then it must match the current character of s. //Continue pattern matching with the next character of both s and p.//2. If the next chara
2013-05-31 10:39:13 2478
原创 [LeetCode]Recover Binary Search Tree
struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};class Solution {//the clue is that if we traverse the tree in inorder, then it
2013-05-31 10:39:09 2231
原创 [LeetCode]Pow(x, n)
class Solution {//divide-and-conquer//classicpublic: double pow(double x, int n) { if (n == 0) return 1.0; // Compute x^{n/2} and store the result into a temporary // variable to avoid unnec
2013-05-31 10:39:05 1952
原创 [LeetCode]Populating Next Right Pointers in Each Node
struct TreeLinkNode { int val; TreeLinkNode *left, *right, *next; TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL) {}};class Solution {public: void connect(TreeLinkNode *roo
2013-05-31 10:39:02 1206
原创 [LeetCode]Plus One
class Solution {public: vector plusOne(vector &digits) { // Start typing your C/C++ solution below // DO NOT write int main() function vector ans; int len = digits.size(); int carry = 1;
2013-05-31 10:38:58 1995
原创 [LeetCode]Permutations II
class Solution {//DFS//always let the next same element go first, //in such a case we can cut down half same permutations //generated by these same element//need more practicepublic: vector > p
2013-05-31 10:38:54 2488
原创 [LeetCode]Permutations
class Solution {//DFSpublic: vector > permute(vector &num) { // Start typing your C/C++ solution below // DO NOT write int main() function int n = num.size(); if(0 == n) return vector >();
2013-05-31 10:38:50 1431
原创 [LeetCode]Permutation Sequence
class Solution {//decompose the big problem into smaller problemprivate: vector numT;//keep record of number state, choosen or not vector factT;//save factorial numberpublic: string getPermutati
2013-05-31 10:38:46 1333
原创 [LeetCode]Path Sum II
struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};class Solution {//record all the path, though dfs is not time efficient bu als
2013-05-31 10:38:41 1068
原创 Sorting
A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order. There are two mainly kind of sorting algori
2013-05-31 10:37:51 1750
原创 [LeetCode]Reverse Linked List II
struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}}; class Solution {//divide this problem into 3 parts//1. previous part, do not need to reverse//2. median pa
2013-05-31 02:39:59 1321
原创 [LeetCode]Restore IP Addresses
class Solution {//DFS//Note: there are 4 special process herepublic: void DFS(int curStep, int curPos, const string& s, string& curAns, vector& ans) { if(s.size()-curPos > (5-curStep)*3)//3. cu
2013-05-31 02:39:50 2262
原创 [LeetCode]Path Sum
struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};class Solution { //if we need to find one path sum of a tree, then dfs is alway
2013-05-30 10:27:47 723
原创 [LeetCode]Pascal Triangle II
class Solution {public: vector getRow(int rowIndex) { // Start typing your C/C++ solution below // DO NOT write int main() function vector ans(rowIndex+2, 0); vector tmp(ro
2013-05-30 10:27:40 891
原创 [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 > ans; ans.resize(numRows);
2013-05-30 10:27:34 1598
原创 [LeetCode]Partition List
struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {public: ListNode *partition(ListNode *head, int x) { // Start typing your C/C++ solution b
2013-05-30 10:27:30 1462
原创 [LeetCode]Palindrome Partitioning II
class Solution {public: int minCut(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function int len = s.size(); vector dp(len+1);//dp[i]: minimum cut between
2013-05-30 10:27:24 1501
原创 [LeetCode]Palindrome Partitioning
class Solution {public: bool IsPalindrome(string str, int startIdx, int endIdx) { while (startIdx < endIdx) { if(str[startIdx] != str[endIdx]) return false; startIdx++; endIdx--;
2013-05-30 10:26:06 1144
原创 [LeetCode]Palindrome Number
class Solution {//compare both the left most and the right most digit, //if not equal return falsepublic: bool isPalindrome(int x) { // Start typing your C/C++ solution below // DO NOT write i
2013-05-30 10:26:01 3654 4
原创 [LeetCode]Next Permutation
class Solution {//from right to left find the minimum larger number to replace the current number//once find, swap(current, minimum larger number), then sort(current+1, end)//find out the regular p
2013-05-30 10:25:57 1631
原创 [LeetCode]N-Queens II
class Solution {//http://www.matrix67.com/blog/archives/266//need more practice, solve N-Queens by bit manipulationpublic: int cnt,upper; int totalNQueens(int n) { // Start typing your C/C++ s
2013-05-30 10:25:53 1389
原创 [LeetCode]N-Queens
class Solution {//using DFS//CheckPosition part may can be optimizedpublic: vector > solveNQueens(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function if(0
2013-05-30 10:25:48 1837
原创 [LeetCode]Multiply Strings
class Solution {//draw it out and then observe it to find out the regular pattern//more practice is neededpublic: string multiply(string num1, string num2) { // Start typing your C/C++ solution
2013-05-30 10:25:43 1873
原创 [LeetCode]Minimum Window Substring
class Solution {//need2FT + hasFT + two pointer + count(check if satisfied)//O(n)public: string minWindow(string S, string T) { // Start typing your C/C++ solution below // DO NOT write int ma
2013-05-30 10:25:29 1956 2
原创 [LeetCode]Minimum Path Sum
class Solution {//DPpublic: int minPathSum(vector > &grid) { // Start typing your C/C++ solution below // DO NOT write int main() function int n = grid.size(); if(n == 0) return 0; int m
2013-05-30 10:25:24 1684
原创 [LeetCode]Minimum Depth of Binary Tree
struct TreeNode { int val; TreeNode *left; TreeNode *right; TreeNode(int x) : val(x), left(NULL), right(NULL) {}};class Solution { //find the minimum step of a tree, bfs works at most timepub
2013-05-30 10:25:19 2497
原创 [LeetCode]Merge Two Sorted Lists
struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {//this is a very simple implementation//one pointer and one pointer's pointerpublic: ListN
2013-05-30 10:25:12 918
原创 [LeetCode]Merge k Sorted Lists
struct ListNode { int val; ListNode *next; ListNode(int x) : val(x), next(NULL) {}};class Solution {//O(nlogk)//using priority_queue to choose current minimum node//node: keep priority_queue
2013-05-30 10:24:49 2536 2
原创 [LeetCode]Merge Intervals
struct Interval { int start; int end; Interval() : start(0), end(0) {} Interval(int s, int e) : start(s), end(e) {}};class Solution {//first sort and then merge, O(nlogn)public: struct comp
2013-05-30 10:24:45 1468
原创 [LeetCode]Median of Two Sorted Arrays
class Solution {//more detail refer to: http://fisherlei.blogspot.com/2012/12/leetcode-median-of-two-sorted-arrays.html//using the method of getting the kth number in the two sorted array to solve t
2013-05-30 10:24:31 1663
原创 Dynamic Programming
Dynamic Programming is an algorithmic paradigm that solves a given complex problem by breaking it into subproblems andstores the results of subproblems to avoid computing the same results again. Follo
2013-05-30 10:22:54 1247
原创 [LeetCode]Merge Sorted Array
class Solution {//write down some cases and find out the regular patternpublic: void merge(int A[], int m, int B[], int n) { // Start typing your C/C++ solution below // DO NOT write int main()
2013-05-30 02:24:55 769
color transfer 颜色转化
2011-12-06
c语言DOS界面菜单式四则运算自编(菜单功能很不错宝贵资源)
2009-03-10
Vc6.0++MFC编程实例4讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例15讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例14讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例13讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例12讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例11讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例10讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例9讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例8讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例7讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例6讲解详细(宝贵资源)
2009-03-10
Vc6.0++MFC编程实例1讲解详细(宝贵资源)
2009-03-09
Vc6.0++MFC编程实例2讲解详细(宝贵资源)
2009-03-09
链表C语言实现 功能齐全
2009-03-09
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人