自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(58)
  • 收藏
  • 关注

原创 Leetcode: Clone Graph

Problem: Clone Graph leetcode java(DFS and BFS 基础)

2014-11-17 12:20:26 290

原创 Leetcode: Divide Two Integers

Problem: Divide two integers without using multiplication, division and mod operator.

2014-11-14 14:19:04 304

原创 Leetcode: Max Points on a Line

Problem: Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.

2014-11-13 12:06:50 436

转载 Leetcode: Subsets (Iterative)

class Solution {public: vector > subsets(vector &s) { // Start typing your C/C++ solution below // DO NOT write int main() function sort(s.begin(),s.end()); int ma

2013-09-15 02:27:29 377

原创 Leetcode: Generate Parentheses

class Solution {public: vector generateParenthesis(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function string s(2*n,'\0'); vecto

2013-03-11 10:38:02 431

原创 Leetcode: Subsets ||

class Solution {public: vector > subsetsWithDup(vector&s) { // Starttyping your C/C++ solution below // DO NOTwrite int main() function set > vv; vector v; vec

2013-03-11 04:40:01 342

原创 Leetcode: Subsets (Recursive)

class Solution {public: vector > subsets(vector &s) { // Start typing your C/C++ solution below // DO NOT write int main() function vector > vv; vector v;

2013-03-05 02:29:01 364

原创 Leetcode: Path Sum

/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti

2013-02-26 10:46:49 208

原创 Leetcode: Flatten Binary Tree to Linked List

/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti

2013-02-22 06:12:34 206

原创 Leetcode: Populating Next Right Pointers in Each Node

/** * Definition for binary tree with next pointer. * struct TreeLinkNode { * int val; * TreeLinkNode *left, *right, *next; * TreeLinkNode(int x) : val(x), left(NULL), right(NULL), next(NULL)

2013-02-19 04:08:11 237

原创 Leetcode: Reverse Integer

class Solution {public: int reverse(int x) { // Start typing your C/C++ solution below // DO NOT write int main() function bool negative=false; if(x<0){

2013-02-12 10:27:27 167

原创 Leetcode: Remove Nth Element from Sorted Linked List

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode *re

2013-02-12 01:14:50 229

原创 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(n==0) return 0;

2013-02-12 00:22:38 181

原创 Leetcode: Permutations

class Solution {public: vector > permute(vector &num) { // Start typing your C/C++ solution below // DO NOT write int main() function vector > result; perm(result,

2013-02-11 06:11:49 250

转载 Leetcode: Roman to Integer

class Solution {public: int romanToInt(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function int result=0; int previous=1001;

2013-02-09 09:58:08 206

转载 Leetcode: Integer to Roman

class Solution {public: #define MAX_LENGTH 5 string intToRoman(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function char roman[4][10

2013-02-08 06:07:57 207

原创 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: ListNode *sw

2013-02-03 10:58:14 269

原创 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 i=0, j=n; w

2013-01-28 22:54:18 215

原创 Leetcode: Combinations

class Solution {public: vector > combine(int n, int k) { // Start typing your C/C++ solution below // DO NOT write int main() function vector > result; for(int i=1

2013-01-28 01:02:26 234

转载 Leetcode: Subsets

class Solution {public: vector > subsets(vector &S) { // Start typing your C/C++ solution below // DO NOT write int main() function sort(S.begin(), S.end()); vec

2013-01-27 09:08:41 271

原创 Leetcode: Word Search

class Solution {public: bool exist(vector > &board, string word) { // Start typing your C/C++ solution below // DO NOT write int main() function for(int i=0;i<board.size()

2013-01-24 13:22:55 257

原创 Leetcode: sqrt

class Solution {public: int sqrt(int x) { // Start typing your C/C++ solution below // DO NOT write int main() function assert(x>=0); if(x==0) return 0

2013-01-24 12:02:33 431

原创 Leetcode: Pow(x,n)

class Solution {public: double pow(double x, int n) { // Start typing your C/C++ solution below // DO NOT write int main() function if(n==0) return 1;

2013-01-22 05:02:42 216

原创 Leetcode: Insert Interval

/** * Definition for an interval. * struct Interval { * int start; * int end; * Interval() : start(0), end(0) {} * Interval(int s, int e) : start(s), end(e) {} * }; */class So

2013-01-22 04:12:33 296

原创 Leetcode: Merge Intervals

/** * Definition for an interval. * struct Interval { * int start; * int end; * Interval() : start(0), end(0) {} * Interval(int s, int e) : start(s), end(e) {} * }; */ bool

2013-01-22 02:47:12 215

原创 Leetcode: Valid Number

class Solution {public: bool isNumber(const char *s) { // Start typing your C/C++ solution below // DO NOT write int main() function bool num=false; bool dot=false

2013-01-22 01:11:30 233

原创 Leetcode: Set Matrix Zeroes

class Solution {public: void setZeroes(vector > &matrix) { // Start typing your C/C++ solution below // DO NOT write int main() function vector r(matrix.size(),false);

2013-01-21 01:43:45 233

原创 Leetcode: Merge Sorted Arrays

class Solution {public: void merge(int A[], int m, int B[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function //if(A==NULL)

2013-01-20 13:11:19 209

原创 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.size()==0) return true

2013-01-20 12:34:46 492

原创 Leetcode: isBST

/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti

2013-01-20 06:14:40 306

原创 Leetcode: Implement strStr

class Solution {public: char *strStr(char *haystack, char *needle) { // Start typing your C/C++ solution below // DO NOT write int main() function //naive O(mn) s

2013-01-20 00:18:08 289

原创 Leetcode: Merge Two Sorted Lists

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode *me

2013-01-19 13:42:39 224

原创 Leetcode: Valid Parentheses

class Solution {public: bool isValid(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function if(s.size()<2) return false;

2013-01-18 22:18:37 231

原创 Leetcode: atoi

class Solution {public: int atoi(const char *str) { // Start typing your C/C++ solution below // DO NOT write int main() function if(str==NULL) return 0;

2013-01-17 04:23:07 295

原创 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 result; i

2013-01-17 02:45:30 352

原创 Leetcode: Decode ways

//first set up the last two cells, then dp forwardclass Solution {public: int numDecodings(string s) { // Start typing your C/C++ solution below // DO NOT write int main() functi

2013-01-16 23:18:33 257

原创 Leetcode: Count and Say

//implement this function iterativelyclass Solution {public: string countAndSay(int n) { // Start typing your C/C++ solution below // DO NOT write int main() function str

2013-01-16 06:59:34 304

原创 Leetcode: Convert Sorted List to Balanced Binary Search Tree

/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *//** * Definition for binary tree * stru

2013-01-15 10:54:31 211

原创 Leetcode: Convert Sorted Array to Binary Search Tree

/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class Soluti

2013-01-15 06:10:29 167

原创 Leetcode: Container With Most Water

//use two pointers: move the shorter one until they meet in the middleclass Solution {public: int maxArea(vector &height) { // Start typing your C/C++ solution below // DO NOT wr

2013-01-14 12:40:32 224

空空如也

空空如也

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

TA关注的人

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