上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 36 下一页
摘要: Simple DP, but notes:1. initialize the array not only for dp[i] += dp[i-1], but also dp[i] += dp[i-1] + grid[i][0];2. Clear that we are using one dime... 阅读全文
posted @ 2015-03-21 07:50 keepshuatishuati 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(i... 阅读全文
posted @ 2015-03-21 07:39 keepshuatishuati 阅读(102) 评论(0) 推荐(0) 编辑
摘要: Use two stacks :class MinStack {private: stack s, minS;public: void push(int x) { if (minS.empty() || x s;public: void push(int x) { ... 阅读全文
posted @ 2015-03-21 07:35 keepshuatishuati 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Iterative: 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : ... 阅读全文
posted @ 2015-03-21 07:31 keepshuatishuati 阅读(132) 评论(0) 推荐(0) 编辑
摘要: Note:Since it merged from end, so1. tmp1, tmp2 = INT_MIN2. tmp1 > tmp2 1 class Solution { 2 public: 3 void merge(int A[], int m, int B[], int n) {... 阅读全文
posted @ 2015-03-21 07:26 keepshuatishuati 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Use merge two looply merge the from the queue. 1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNod... 阅读全文
posted @ 2015-03-21 07:14 keepshuatishuati 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 1 /** 2 * Definition for an interval. 3 * struct Interval { 4 * int start; 5 * int end; 6 * Interval() : start(0), end(0) {} 7 * ... 阅读全文
posted @ 2015-03-21 06:20 keepshuatishuati 阅读(112) 评论(0) 推荐(0) 编辑
摘要: O(m + n):Note:return rec[1] not rec[0]. 1 class Solution { 2 public: 3 double findMedianSortedArrays(int A[], int m, int B[], int n) { 4 i... 阅读全文
posted @ 2015-03-21 06:13 keepshuatishuati 阅读(114) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int maxSubArray(int A[], int n) { 4 int result = A[0], sum = A[0]; 5 for (int i = 1; i < n; i++) {... 阅读全文
posted @ 2015-03-21 05:54 keepshuatishuati 阅读(92) 评论(0) 推荐(0) 编辑
摘要: Similar to maximum sum subarray, but need a gmin to record the global minimum to handle negative numbermultiplication. 1 class Solution { 2 public: 3 ... 阅读全文
posted @ 2015-03-21 05:51 keepshuatishuati 阅读(124) 评论(0) 推荐(0) 编辑
上一页 1 ··· 24 25 26 27 28 29 30 31 32 ··· 36 下一页