随笔分类 -  Algorithm

上一页 1 ··· 8 9 10 11 12 13 14 15 16 下一页
classic algorithm, problem
摘要:class Solution {public: int searchInsert(int A[], int n, int target) { if (A == NULL || n target) { q = mi; } els... 阅读全文
posted @ 2014-06-20 16:19 卖程序的小歪 阅读(161) 评论(0) 推荐(0)
摘要:class Solution {private: int getDirection(int A[], int idx, int target, bool isDefaultBack) { int r = A[idx] - target; if (r == 0) { ... 阅读全文
posted @ 2014-06-12 19:23 卖程序的小歪 阅读(219) 评论(0) 推荐(0)
摘要:class Solution {public: vector grayCode(int n) { vector res; res.push_back(0); long pow2 = 1; for (int i=1; i grayCode... 阅读全文
posted @ 2014-06-12 14:42 卖程序的小歪 阅读(143) 评论(0) 推荐(0)
摘要:class Solution {private: const static char* pattern[]; const static char* roman_digit[];public: string intToRoman(int num) { if (num ... 阅读全文
posted @ 2014-06-12 14:01 卖程序的小歪 阅读(158) 评论(0) 推荐(0)
摘要:class Solution {public: char *strStr(char *haystack, char *needle) { if (haystack == NULL || needle == NULL) return NULL; int wpos[25... 阅读全文
posted @ 2014-06-06 20:06 卖程序的小歪 阅读(181) 评论(0) 推荐(0)
摘要:class Solution {public: ListNode *swapPairs(ListNode *head) { ListNode *a = NULL; ListNode *b = NULL; ListNode *tail = NULL; ... 阅读全文
posted @ 2014-06-03 21:48 卖程序的小歪 阅读(156) 评论(0) 推荐(0)
摘要: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; ... 阅读全文
posted @ 2014-05-29 19:55 卖程序的小歪 阅读(152) 评论(0) 推荐(0)
摘要:class Solution {private: static int compare(const Interval& a, const Interval& b) { return a.start merge(vector &intervals) { vector... 阅读全文
posted @ 2014-05-29 19:21 卖程序的小歪 阅读(217) 评论(0) 推荐(0)
摘要:class Solution {public: ListNode *mergeKLists(vector &lists) { ListNode* merged = NULL; for (int i=0; ival val) { n... 阅读全文
posted @ 2014-05-29 18:35 卖程序的小歪 阅读(195) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2014-05-29 16:56 卖程序的小歪 阅读(199) 评论(0) 推荐(0)
摘要:class Solution {public: ListNode *mergeTwoLists(ListNode *l1, ListNode *l2) { ListNode* p = l1; ListNode* q = l2; ListNode* he... 阅读全文
posted @ 2014-05-29 13:52 卖程序的小歪 阅读(181) 评论(0) 推荐(0)
摘要:class Solution {public: string getPermutation(int n, int k) { k--; if (n nums(n, 0); long seg = 1; for (int i=0; i= se... 阅读全文
posted @ 2014-05-29 09:57 卖程序的小歪 阅读(165) 评论(0) 推荐(0)
摘要: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++) { ... 阅读全文
posted @ 2014-05-29 08:42 卖程序的小歪 阅读(135) 评论(0) 推荐(0)
摘要:class Solution {public: ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) { ListNode* p = l1; ListNode* q = l2; ListNode* re... 阅读全文
posted @ 2014-05-27 22:13 卖程序的小歪 阅读(202) 评论(0) 推荐(0)
摘要:const char* lookup[] = {" ", "", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxy... 阅读全文
posted @ 2014-05-27 20:43 卖程序的小歪 阅读(171) 评论(0) 推荐(0)
摘要: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... 阅读全文
posted @ 2014-05-27 19:54 卖程序的小歪 阅读(228) 评论(0) 推荐(0)
摘要:class Solution { public: vector > permuteUnique(vector &num) { vector > result; if (num.size() path; dfs(n... 阅读全文
posted @ 2014-05-27 19:00 卖程序的小歪 阅读(170) 评论(0) 推荐(0)
摘要:class Solution { public: vector > generateMatrix(int n) { vector > matrix; if (n (n, 0)); }... 阅读全文
posted @ 2014-05-27 15:47 卖程序的小歪 阅读(173) 评论(0) 推荐(0)
摘要:class Solution { public: vector spiralOrder(vector > &matrix) { vector ret; int cols = 0; ... 阅读全文
posted @ 2014-05-27 14:42 卖程序的小歪 阅读(210) 评论(0) 推荐(0)
摘要:class Solution {public: int maxProfit(vector &prices) { int len = prices.size(); if (len maxv) { maxv = cur; ... 阅读全文
posted @ 2014-05-20 10:46 卖程序的小歪 阅读(183) 评论(0) 推荐(0)

上一页 1 ··· 8 9 10 11 12 13 14 15 16 下一页