- 博客(23)
- 收藏
- 关注
原创 [leetcode]Distinct Subsequences
class Solution { public: int numDistinct(string S, string T) { // Start typing your C/C++ solution below // DO NOT write int main() function if (T.empty() || S.empty()
2013-10-07 12:48:50 345
原创 [leetcode]Populating Next Right Pointers in Each Node II
class Solution { public: void insert_node(TreeLinkNode *&tail, TreeLinkNode *p) { p->next = NULL; tail->next = p; tail = p; } TreeLinkNode *delete_node(TreeL
2013-10-07 12:46:16 451
原创 [leetcode]Word Break II
class Solution { public: vector wordBreak(string s, unordered_set &dict) { // Note: The Solution object is instantiated only once and is reused by each test case. int n = (int)
2013-10-07 12:43:44 1284
原创 [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(numRows); for (i
2013-10-06 11:47:00 333
原创 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(rowIndex + 1); res[0
2013-10-06 11:44:56 347
原创 [leetcode]Triangle
class Solution { public: int minimumTotal(vector > &triangle) { // Start typing your C/C++ solution below // DO NOT write int main() function vector res(triangle.size(
2013-10-06 11:39:27 358
原创 [leetcode]Best Time to Buy and Sell Stock III
class Solution { public: int maxProfit(vector &prices) { // Note: The Solution object is instantiated only once and is reused by each test case. if (prices.empty()) return 0;
2013-10-06 11:24:33 512
原创 [leetcode]Best Time to Buy and Sell Stock II
class Solution { public: int maxProfit(vector &prices) { // Start typing your C/C++ solution below // DO NOT write int main() function int res = 0; for (size_t i =
2013-10-06 11:08:09 527
原创 [leetcode]Best Time to Buy and Sell Stock
class Solution { public: int maxProfit(vector &prices) { // Note: The Solution object is instantiated only once and is reused by each test case. int min_price = INT_MAX;
2013-10-06 11:05:45 798
原创 [leetcode]Binary Tree Maximum 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-10-06 10:59:25 481
原创 [leetcode]Valid Palindrome
class Solution { public: bool isPalindrome(string s) { // Start typing your C/C++ solution below // DO NOT write int main() function string t; for (size_t i = 0; i
2013-10-06 10:43:08 379
原创 [leetcode]Word Ladder
class Solution { public: int ladderLength(string start, string end, unordered_set &dict) { queue > Q; unordered_set visited; Q.push(make_pair(start, 1)); visited.insert(start); int res = 0;
2013-10-06 10:39:16 425
原创 [leetcode]Longest Consecutive Sequence
class Solution { public: int longestConsecutive(vector &num) { // Start typing your C/C++ solution below // DO NOT write int main() function unordered_set S; for (size_t i = 0; i < num.size()
2013-10-06 10:25:14 328
原创 [leetcode]Sum Root to Leaf Numbers
class Solution { public: void dfs(TreeNode *root, int num, int &result) { if (root == NULL) return; num = 10 * num + root->val; if (root->left == NULL && root->right =
2013-10-06 10:20:46 354
原创 [leetcode]Surrounded Regions
class Solution { public: int rows, cols; void dfs(int x, int y, vector>& board) { if (x = rows || y = cols || board[x][y] != 'O') return; board[x][y] = 'V';
2013-10-06 10:18:07 309
原创 [leetcode]Palindrome Partitioning
class Solution { public: vector> res; vector> dp; string str; int n; void dfs(int id, vector& pres) { if (id >= n) { res.push_back(pres); }
2013-10-06 10:16:50 314
原创 [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 n = s.size(); vector> dp(n, vector(n, false)); for (int i =
2013-10-06 10:12:46 334
原创 [leetcode]Gas Station
class Solution { public: int canCompleteCircuit(vector &gas, vector &cost) { // Note: The Solution object is instantiated only once and is reused by each test case. int sum = 0
2013-10-06 10:10:39 1001
原创 [leetcode]Candy
class Solution { public: void gao(const vector &ratings, vector &res) { int n = (int)ratings.size(); int cnt = 0; int height = -INT_MAX; for (int i = 0; i
2013-10-06 10:08:37 902
原创 [leetcode]Signle Number
class Solution { public: int singleNumber(int A[], int n) { // Note: The Solution object is instantiated only once and is reused by each test case. int res = 0; for (i
2013-10-06 10:06:50 361
原创 [leetcode]Single Number II
class Solution { public: int singleNumber(int A[], int n) { // Note: The Solution object is instantiated only once and is reused by each test case. vector cnt(32, 0);
2013-10-06 10:06:14 675
原创 [leetcode]Copy List with Random Pointer
/** * Definition for singly-linked list with a random pointer. * struct RandomListNode { * int label; * RandomListNode *next, *random; * RandomListNode(int x) : label(x), next(NU
2013-10-06 10:05:09 1423
原创 [leetcode]Word Break
class Solution { public: bool wordBreak(string s, unordered_set &dict) { // Note: The Solution object is instantiated only once and is reused by each test case. int n = (int)s.
2013-10-06 10:03:59 1297 1
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人