- 博客(57)
- 资源 (4)
- 收藏
- 关注
原创 leetcode Longest Common Prefix
代码class Solution {public: string longestCommonPrefix(vector &strs) { string result = ""; int n = strs.size(); if(n==0) return result; for(in
2014-10-29 21:21:17 335
原创 leetcode 3Sum Closest
代码class Solution {public: int threeSumClosest(vector &num, int target) { int res = 0; int size = num.size(); sort(num.begin(), num.end()); int minDi
2014-10-29 21:09:40 317
原创 leetcode 3Sum
参考代码class Solution {public: vector > threeSum(vector &num) { vector > res; vector temp; int size = num.size(); if(size<3) return res;
2014-10-29 20:13:00 425
原创 leetcode Integer to Roman
代码class Solution {public: string intToRoman(int num) { if(num3999) return ""; int digit = 1000; vector digits; while(digit>0)
2014-10-29 17:01:32 285
原创 leetcode
利用动态规划参考 代码class Solution {public: string longestPalindrome(string s) { int length = s.length(); if(length<=1) return s; bool flag[length][lengt
2014-10-29 16:24:23 301
原创 leetcode Longest Substring Without Repeating Characters
此题can代码class Solution {public: int lengthOfLongestSubstring(string s) { int res = 0; int size = s.length(); if(size==0) return res;
2014-10-29 15:58:07 286
原创 leetcode Generate Parentheses
采用递归算法代码class Solution {public: vector generateParenthesis(int n) { string tempResult; vector result; generateParenthesisHelper(result, tempResult, n, n);
2014-10-29 12:58:44 381
原创 leetcode Count and Say
代码class Solution {public: string countAndSay(int n) { string s = ""; if(n==0) return s; for(int i = 1; i <= n; ++i) s = countAn
2014-10-27 20:43:04 406
原创 leetcode Valid Parentheses
代码class Solution {public: bool isValid(string s) { int length = s.length(); if(length==0) return true; stack brackets; for(int i =
2014-10-27 20:05:02 309
原创 leetcode Remove Nth Node From End of List
根据题目要求, 可以设置两个指针,slow和fast,fast先走n步,
2014-10-27 19:23:34 346
原创 leetcode Find Minimum in Rotated Sorted Array II
参考http://blog.csdn.net/linhuanmars/article/details/40449299代码class Solution {public: int findMin(vector &num) { if(num.size()==0) return 0; int l =
2014-10-25 22:34:47 289
原创 leetcode Search in Rotated Sorted Array II
此题参考 http://blog.csdn.net/linhuanmars/article/details/20588511
2014-10-25 20:51:15 314
原创 leetcode Next Permutation
代码class Solution {public: void nextPermutation(vector &num) { int length = num.size()-1; while(length>0) { if(num[length-1] < nu
2014-10-25 18:59:12 305
原创 leetcode Sudoku Solver
参考代码class Solution {public: void solveSudoku(vector > &board) { for(int i = 0; i < 9; ++i) for(int j = 0; j < 9; ++j) { if(board[i][j]
2014-10-22 20:09:38 267
原创 leetcode Valid Sudoku
此题参考 http://www.cnblogs.com/TenosDoIt/p/3800485.html
2014-10-22 19:46:38 360
原创 leetcode Multiply Strings
代码class Solution {private: int shiftLeftNum;public: string multiply(string num1, string num2) { string res; int len1 = num1.length(); int len2 = num2.length(
2014-10-22 19:13:00 343
原创 leetcode Combination Sum VS Combination Sum II
利用递归进行ombination Sum VS Combination Sum II 两题解法十分相似, 区别仅在于是否可以
2014-10-21 19:58:14 374
原创 VS2012+OpenCV246 读入图片并修改像素值
代码#includeusing namespace cv;int main(){ IplImage* srcImage = cvLoadImage("HEVCStructureInfo#13.png"); if(srcImage==NULL) return -1; IplImage* dstImage ; dstImage = cvCloneImage(src
2014-10-20 21:36:14 874
原创 leetcode Remove Element
class Solution {public:int removeElement(int A[], int n, int elem) {if(n==0)return 0;for(int i = n-1; i>=0; --i){if(elem==A[i]){for(int j = i; j {A[j] = A[j+1];}n--;}}
2014-10-15 21:23:34 263
原创 leetcode Pow(x,n)
此题需要注意的是n的tclass Solution {public: double pow(double x, int n) { if(n==0) return 1; if(n==1) return x; double temp = pow(x, abs(n/2));
2014-10-15 20:32:44 292
原创 leetcode Permutations II
参考博客http://www.cnblogs.com/tenosdoit/p/3662644.html
2014-10-15 19:38:32 369
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人