![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
原创
文章平均质量分 66
gunxueqiucjw
这个作者很懒,什么都没留下…
展开
-
python简单易懂的全排列实现
b = [0,0,0,0,0,0,0] %临时变量,记录每一种排序的可能性count = 0 %记录当前排列到第几位c = [] %全局变量记录下所有的排列情况def full_array(a): global b,count,c if len(a) == 1: b[count] = a[0] c.append(b) retu原创 2013-07-15 10:49:03 · 966 阅读 · 1 评论 -
leetcode sum from root to leaf
Just the code. This is a very easy one. Using DFS ALG/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : va原创 2015-01-04 01:27:21 · 517 阅读 · 0 评论 -
leetcode surronded region
#include #include #include using namespace std;class Solution {public: int** visited; int *circle_r, *circle_c; int st, ed, row, col; void solve(vector > &board) { int原创 2015-01-04 01:24:25 · 720 阅读 · 0 评论 -
leetcode Palindrome I and II comparison
The easier one "Palindrome I" is solved by DFS ALG1. From left to right, judge the substr(0, i) is Palindrome or not. If it is, add it to one of the element of the answer. Then use partition to find原创 2015-01-02 09:58:08 · 505 阅读 · 0 评论 -
leetcode Unique BST
总结一下这题:碰到这种计数问题应该本能想到用dynamic programming的思路又正好是关于tree的问题,所以应该先想到左子树的结果与右子树的结果的某种操作,这道题正好应该选择乘法操作class Solution {public: // DFS method int *lookup; int numTrees(int n) { // re原创 2014-12-23 14:11:35 · 582 阅读 · 0 评论 -
leetcode Majority Element
这题限制时间复杂度是O(n) 才能通过所有测试,之前写了一个现sorting的,复杂度是O(nlogn),Time Limited Exceed!!!网上看到一个很赞的算法Moore voting algorithm, Stackoverflow 上有很好的解释class Solution {public: int majorityElement(vector &nu原创 2014-12-23 08:19:40 · 901 阅读 · 0 评论 -
leetcode validate binary search tree
一道Easy级别的题目Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than原创 2014-12-23 09:16:54 · 538 阅读 · 0 评论 -
LRU leetcode 代码实现
很奇怪,我自己明明能跑得通的程序放在leetcode上面测试会出现Runtime原创 2014-04-21 01:46:21 · 963 阅读 · 1 评论 -
leetcode Read N Characters Given Read4
// Forward declaration of the read4 API.int read4(char *buf);class Solution {public: /** * @param buf Destination buffer * @param n Maximum number of characters to read * @ret原创 2014-12-22 13:51:47 · 1009 阅读 · 0 评论 -
leetcode Binary Tree Upside Down
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class So原创 2014-12-22 14:00:19 · 719 阅读 · 0 评论 -
leetcode Find minimum in rotated sorted array
Just the following code for both duplicated or not.原创 2014-11-12 07:02:41 · 637 阅读 · 0 评论 -
leetcode Min stack
It is very easy to get idea of this problem. Just use an auxiliary stack (s_a) to store the current minimum element in the data stack (s_d). But leetcode has a strong constrain in the memory size, alw原创 2014-11-11 02:53:15 · 621 阅读 · 0 评论 -
最简单配置方法!无线网络联网状态下 VirtualBox实现Window主机与虚拟机互相访问
网上关于VirtualBox的帖子实在是原创 2014-05-27 21:03:22 · 8634 阅读 · 0 评论 -
CentOS6.5 U盘安装(解决了FAT32格式造成的不能复制iso文件至U盘根目录问题)
本人安装过程遇见了上述标题中的问题,百度之google之,发现大部分人都直接说出了再遇到image找不到的解决方案是将iso整个文件在放置到刻录好的U盘的根目录下,但是正如http://blog.sina.com.cn/s/blog_51c1ed0501018lf2.html 下面的留言一样,都没法完成iso文件的复制问题。在此本人瞎捣鼓了一下午,貌似是解决了这个问题,还望各位大侠实验之原创 2014-01-01 18:41:37 · 8102 阅读 · 3 评论 -
leetcode word break I && II
Two dynamic programming problemproblem II can use the code of problem IWord Break Iclass Solution {public: int longestWord(unordered_set dict) { unordered_set::iterator it;原创 2015-01-02 16:13:05 · 762 阅读 · 0 评论