自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(65)
  • 资源 (1)
  • 收藏
  • 关注

原创 wamp server搭建

参考下载wampserver,在php100把iis软件关掉,不然会影响wamp server的使用(1)新建虚拟目录 php                  a. WampServer菜单-->Apache-->alias目录-->添加一个alias                  b.输入虚拟目录的访问名称:如 php             

2014-04-03 08:45:29 512

原创 Palindrome Number

class Solution {public: bool isPalindrome(int x) { if(x<0) return false; int a=x,b=x; int te=0; while(a!=0) { te=te*10+a%10;

2014-03-27 21:57:38 311

原创 Valid Sudoku

class Solution {public: bool isValidSudoku(vector > &board) { for(int i=0;i<9;i++) for(int j=0;j<9;j++) { if(board[i][j]!='.') if(!i

2014-03-26 19:58:26 356

原创 Sudoku Solver

class Solution {public: void solveSudoku(vector > &board) { solve(board); } bool solve(vector>&board) { for(int i=0;i<9;i++) for(int j=0;j<9;j++)

2014-03-26 19:48:48 389

原创 Combination Sum

class Solution {public: vector>res; vector > combinationSum(vector &candidates, int target) { vectorpath; combination(candidates,target,path,0); return res; }

2014-03-25 19:25:44 327

原创 Divide Two Integers

class Solution {public: int divide(int dividend, int divisor) { if(dividend==0) return 0; int tag=0; if(dividend>0&&divisor0) tag=1; long l

2014-03-25 19:04:18 391

原创 Remove Duplicates from Sorted Array II

class Solution {public: int removeDuplicates(int A[], int n) { if(n<=1) return n; int j=1; int value=A[0]; int count=1; for(int i=1;i<n;i++)

2014-03-25 18:18:47 280

原创 Generate Parentheses

class Solution {public: vectorres; vector generateParenthesis(int n) { generate(0,2*n,0,0,""); return res; } void generate(int dep,int maxdep,int leftnum,int lefttotal

2014-03-24 21:32:59 306

原创 Unique Binary Search Trees II

class Solution {public: vector generateTrees(int n) { return generate(0,n-1); } vector generate(int begin,int end) { vectorres; if(begin>end) {

2014-03-24 20:18:54 427

原创 Convert Sorted List to Binary Search Tree

class Solution {public: TreeNode *sortedListToBST(ListNode *head) { ListNode *p; int count=0; p=head; while(p!=NULL) { count++; p=p

2014-03-24 19:17:14 282

原创 Convert Sorted Array to Binary Search Tree

智商是硬伤啊,昨天在华为做了一道简单的递归都没写出来,尼玛,现在想想实在是愚蠢至极,还特么想拿华为当垫脚石,递归都不会class Solution {public: TreeNode *sortedArrayToBST(vector &num) { return sorta(num,0,num.size()-1); } TreeNode

2014-03-24 18:21:59 381

原创 Insert Interval

class Solution {public: vector insert(vector &intervals, Interval newInterval) { vectorres; for(int i=0;i<intervals.size();i++) { if(intervals[i].end<newInterv

2014-03-22 22:03:46 358

原创 Unique PatUnique Paths II

class Solution {public: int uniquePathsWithObstacles(vector > &obstacleGrid) { if(obstacleGrid.size()==0) return 0; int wide=obstacleGrid.size(); int len=obstacleGr

2014-03-22 21:19:41 324

原创 Best Time to Buy and Sell Stock III

class Solution {public: int maxProfit(vector &prices) { if(prices.size()<=1) return 0; int left[prices.size()]; int minp=prices[0]; left[0]=0;

2014-03-22 20:43:46 295

原创 Wildcard Matching

class Solution {public: bool isMatch(const char *s, const char *p) { const char *ss=s; const char *star=NULL; while(*s!='\0') { if(*s==*p||*s=

2014-03-21 22:50:44 311

原创 Word Ladder

class Solution {public: int ladderLength(string start, string end, unordered_set &dict) { queue>q; unordered_setvisited; q.push(make_pair(start,1)); visited.insert

2014-03-21 15:13:33 313

原创 Word Break II

class Solution {public:vectorres;vectortemp;vector*dp;vector wordBreak(string s,unordered_set&dict){ dp=new vector[s.size()]; for(int i=0;i<s.size();i++) for(int j=i;j<s.size();j++)

2014-03-21 14:40:25 567

原创 Palindrome Partitioning II

12定义函数D[i,n] = 区间[i,n]之间最小的cut数,n为字符串长度 a   b   a   b   b   b   a   b   b   a   b   a                     i                                  n如果现在求[i,n]之间的最优解?应该是多少?简单看一看,至少有下面一个解 a   b

2014-03-20 20:53:39 351

原创 Palindrome Partitioning

class Solution {public: vector> partition(string s) { vector>res; vectorpath; if(s.size()==0) return res; store(res,path,s); } void store(vector

2014-03-20 20:04:06 307

原创 binary tree zigzag Level Order Traversal

class Solution {public: vector > zigzagLevelOrder(TreeNode *root){ vector>res; if(root==NULL) return res; vectorpath; vectorpath_val; path_val.

2014-03-20 19:21:10 338

原创 Spiral Matrix

今天的几道题都没怎么搞懂。。class Solution {public: vector spiralOrder(vector > &matrix) { vectorans; if(matrix.size()==0) return ans; int x1=0,x2=matrix.size()-1,y1=0,y2=ma

2014-03-17 20:01:18 391

原创 Rotate Image

Matrix[i][j]-------->>>>Matrix[j][n - i]每4个元素为一组相互交换。class Solution {public: void rotate(vector > &matrix) { int n=matrix.size()-1; for(int i=0;i<n;i++) fo

2014-03-17 18:54:26 324

原创 Largest Rectangle in Histogram

>>>>>>class Solution {public: int largestRectangleArea(vector &height) { int maxarea=0; stacks; for(int i=0;i<height.size();i++) { if(s.empty())

2014-03-17 12:52:44 326

原创 Edit Distance

现在觉得看懂了,但是几天后要是再做的话,还是不会,一定要学会dpclass Solution {public: int minDistance(string word1, string word2) { vector>f(word1.size()+1,vector(word2.size()+1)); for(int i=0;i<word1.size()+1

2014-03-16 21:20:33 372

原创 Binary Tree Level Order Traversal

class Solution {public: vector > levelOrder(TreeNode *root) { vector path; vectorpath_val; vector> res; if(root==NULL) return res; path.push_ba

2014-03-16 13:37:35 320

原创 Binary Tree Level Order Traversal II

class Solution {public: vector > levelOrderBottom(TreeNode *root) { vector path; vectorpath_val; vector> res; if(root==NULL) return res; path.p

2014-03-16 13:33:54 354

转载 static

转载的Static关键字用法总结static关键字是C, C++中都存在的关键字。static从字面理解,是“静态的“的 意思,与此相对应的,应该是“动态的“。static的作用主要有以下3个:1、扩展生存期;2、限制作用域;3、唯一性;1、扩展生存期这一点主要是针对普通局部变量和static局部变量来说的。声

2014-03-15 22:30:04 361

转载 c++指针和引用的区别

参考引用:引用是一个对象的别名,主要用于函数参数和返回值类型,符号X&表示X类型的引用。区别:          1、首先,引用不可以为空,但指针可以为空。前面也说过了引用是对象的别名,引用为空——对象都不存在,怎么可能有别名!故定义一个引用的时候,必须初始化。因此如果你有一个变量是用于指向另一个对象,但是它可能为空,这时你应该使用指针;   如果变量总是指向一个对象,i.e.

2014-03-15 16:51:34 339

原创 Decode Ways

class Solution {public: int numDecodings(string s) { if(s.size()==0) return 0; int f[s.size()]; if(s[0]=='0') f[0]=0; else f[0]=1;

2014-03-15 14:48:39 351

原创 Construct Binary Tree from Preorder and Inorder Traversal

class Solution {public: TreeNode *buildTree(vector &preorder, vector &inorder) { if(inorder.size()==0) return NULL; return traverse(preorder,0,preorder.size()-1,inorde

2014-03-15 13:47:42 445

原创 Construct Binary Tree from Inorder and Postorder Traversal

class Solution {public: TreeNode *buildTree(vector &inorder, vector &postorder) { if(inorder.size()==0) return NULL; return traverse(inorder,0,inorder.size()-1,postorde

2014-03-15 13:37:23 422

转载 auto register static extern

auto修饰符仅在语句块内部使用,初始化可为任何表达式,其特点是当执行流程进入该语句块的时候执行初始化操作,没有默认值。使用register修饰符修饰变量,将暗示编译程序相应的变量将被频繁地使用,如果可能的话,应将其保存在CPU的寄存器中,以加快其存储速度。static静态变量声明符。在声明它的程序块,子程序块或函数内部有效,值保持,在整个程序期间分配存储器

2014-03-14 23:32:20 512

原创 max points on a line

const double INF=1E9;class Solution {public: int maxPoints(vector &points) { if(points.size()==0) return 0; unordered_mapmp; int res=1; for(int i=

2014-03-14 21:10:15 309

原创 Trapping Rain Water

一个点所能容纳的水由它左侧和右侧的最大高度决定,两次扫描得到最大高度,这个点能容纳的水量是由最大高度里面的最小值减去点的高度决定class Solution {public: int trap(int A[], int n) { if(n<=2) return 0; int leftmax[n]; leftmax[

2014-03-14 14:53:40 338

原创 Valid Number

完全就是照打一遍class Solution {public: bool isNumber(const char *s) { if(s==NULL) return false; while(*s==' ') s++; if(*s=='+'||*s=='-') s+

2014-03-14 14:03:03 299

原创 Maximal Rectangle

不会写。。。class Solution {public: int f[1000][1000]; int maximalRectangle(vector > &matrix) { for(int i=0;i<matrix.size();i++) f[i][0]=matrix[i][0]=='1'?1:0; for(in

2014-03-14 12:57:12 353

转载 C/C++堆栈

转C/C++堆栈指引前言    我们经常会讨论这样的问题:什么时候数据存储在飞鸽传书堆栈(Stack)中,什么时候数据存储在堆(Heap)中。我们知道,局部变量是存储在堆栈中的;debug时,查看堆栈可以知道函数的调用顺序;函数调用时传递参数,事实上是把参数压入堆栈,听起来,堆栈象一个大杂烩。那么,堆栈(Stack)到底是如何工作的呢? 本文将详解C/C

2014-03-14 11:25:40 477

转载 堆和栈

转载的堆栈在计算机领域,堆栈是一个不容忽视的概念,但是很多人甚至是计算机专业的人也没有明确堆栈其实是两种数据结构。要点:堆:顺序随意栈:先进后出堆和栈的区别一、预备知识—程序的内存分配一个由c/C++编译的程序占用的内存分为以下几个部分1、栈区(stack)— 由编译器自动分配释放 ,存放函数的参数值,局部

2014-03-14 11:19:32 314

转载 Interleaving String

Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.When s3 = "aadbbbaccc",

2014-03-13 20:36:29 309

原创 Search in Rotated Sorted Array II

class Solution {public: bool search(int A[], int n, int target) { for(int i=0;i<n;i++) { if(A[i]==target) return true; } return false

2014-03-13 19:56:32 348

php和mysql web开发(原书第4版)源代码

php和mysql web开发(原书第4版)源代码

2014-04-03

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除