
leetcode
zhidao_wenge
这个作者很懒,什么都没留下…
展开
-
fullJustify
vectorstring> fullJustify(vectorstring> &words, int L) { vectorstring> result; if(words.empty() || L 0) return result; int i = 0, begin = 0, end = 0; int原创 2015-04-18 13:39:26 · 452 阅读 · 0 评论 -
leetcode Palindrome Partitioning
vector tmp_result; vector > result; vector > is_division; int str_length; void dpDivision(const string &str) { for(int i = str_length - 1; i >= 0; --i) {原创 2015-06-02 19:53:21 · 580 阅读 · 0 评论 -
leetcode Word Break II
int length; vector one_result; vector result; vector > is_word; void backTrack(string &s, int last, int index, vector &one_result) { if(last == length)原创 2015-06-07 10:58:04 · 449 阅读 · 0 评论 -
leetcode Word Ladder II
vectorstring> one_result; vectorvectorstring> > result; mapstring, int> word_deep_map; //某个单词在第几层上。 int word_lenght; /* 宽度搜索 建立graph(记录单词的层次) */ void bfs(string &start, string &end, setstri原创 2015-06-07 10:53:46 · 508 阅读 · 0 评论 -
leetcode House Robber II
动态规划:假设抢到第i个房间了, money[i] = max(num[i] + money[i-2], money[i-1]); 因为是一个圈,要记录i是来自哪里,用于判断最后一个的最大值是否来自最开始的那个(ffuckk,不会描述) vector money; vector pre_index;//记录当前这个钱 是从哪个房间来的 int lenght;原创 2015-06-09 13:21:01 · 301 阅读 · 0 评论 -
leetcode Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 该方法的核心是将原问题转变成一个寻原创 2015-07-04 10:14:48 · 415 阅读 · 0 评论 -
leetcode Median of Two Sorted Arrays
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). 该方法的核心是将原问题转变成一个寻原创 2015-07-04 10:08:07 · 249 阅读 · 0 评论