05 2014 档案
摘要:class Solution {public: void merge(int A[], int m, int B[], int n) { int mi = m + n - 1; int ai = m - 1; int bi = n - 1; ...
阅读全文
摘要:class Solution {private: static int compare(const Interval& a, const Interval& b) { return a.start merge(vector &intervals) { vector...
阅读全文
摘要:class Solution {public: ListNode *mergeKLists(vector &lists) { ListNode* merged = NULL; for (int i=0; ival val) { n...
阅读全文
摘要:Given an absolute path for a file (Unix-style), simplify it.For example,path="/home/", =>"/home"path="/a/./b/../../c/", =>"/c"click to show corner cas...
阅读全文
摘要:class Solution {public: ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { ListNode* p = l1; ListNode* q = l2; ListNode* he...
阅读全文
摘要:class Solution {public: string getPermutation(int n, int k) { k--; if (n nums(n, 0); long seg = 1; for (int i=0; i= se...
阅读全文
摘要:class Solution {public: int climbStairs(int n) { if (n < 1) return 0; int a = 0; int b = 1; for (int i=0; i<n; i++) { ...
阅读全文
摘要:参考架构Architecture from OpenStack Install GuideReference Architecture Network Isolation在本次部署中,我们采用了OpenStack中新的网络管理组件(neutron),具体参见安装指导。右图为该网络部署结构的示意,分为...
阅读全文
摘要:class Solution {public: ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) { ListNode* p = l1; ListNode* q = l2; ListNode* re...
阅读全文
摘要:const char* lookup[] = {" ", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxy...
阅读全文
摘要:Given a stringsconsists of upper/lower-case alphabets and empty space characters' ', return the length of last word in the string.If the last word doe...
阅读全文
摘要:class Solution { public: vector > permuteUnique(vector &num) { vector > result; if (num.size() path; dfs(n...
阅读全文
摘要:class Solution { public: vector > generateMatrix(int n) { vector > matrix; if (n (n, 0)); }...
阅读全文
摘要:class Solution { public: vector spiralOrder(vector > &matrix) { vector ret; int cols = 0; ...
阅读全文
摘要:看到构造语意的其中一节“继承体系下的对象构造”(5.2节)的最后,看来原文,发现侯杰的翻译有问题,怪不得读起来不顺。What about when providing an argument for a base class constructor? Is it still physically s...
阅读全文
摘要:class Solution {public: int maxProfit(vector &prices) { int len = prices.size(); if (len maxv) { maxv = cur; ...
阅读全文
摘要:class Solution {public: bool isScramble(string s1, string s2) { int len = s1.length(); if (len == 1 && s1[0] == s2[0]) return true; ...
阅读全文
摘要:class Solution {public: bool search(int A[], int n, int target) { if (n A[mid]) { right = mid; sep = A[mid]; ...
阅读全文
摘要:class Solution {public: int canCompleteCircuit(vector &gas, vector &cost) { int len = gas.size(); if (len diff(len, 0); for (...
阅读全文
摘要:class Solution {public: ListNode *insertionSortList(ListNode *head) { if (head == NULL) return NULL; ListNode* sorted_head = head; ...
阅读全文
摘要:>Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.class Solution {public: int m...
阅读全文
摘要:好久没写动态规划,中午听到学长们讨论的一道题,就是给出一组硬币面额,和一个目标数值,求有几种找零方式(想半天没想清楚)#include #include using namespace std;int count(int* s, int m, int n) { if (n == 0) retu...
阅读全文
摘要:class Solution{ public: int maxArea(vector& height) { int len = height.size(), low = 0, high = len -1 ; int maxArea = 0; ...
阅读全文
摘要:class Solution {private: vector result;public: vector wordBreak(string s, unordered_set &dict) { vector > dp; result.clear(); ...
阅读全文
摘要:class Solution {private: int* memo;public: bool wordBreak(string s, unordered_set &dict) { memo = new int[s.length() + 1]; for (in...
阅读全文
摘要:int sunday(string str, string pattern) { int str_len = str.length(); int pat_len = pattern.length(); int char_pos[256]; for (int i = 0...
阅读全文
摘要:```cppclass Solution {public: void connect(TreeLinkNode *root) { if (root == NULL) return; queue que; que.push(root); i...
阅读全文