摘要: 先解释一下,为什么从09年开始就一直使用ubuntu10.10,大三的时候开始接触虚拟机VmWare使用Ubuntu。那时不懂什么是LTS,在这个虚拟机上安装了vim,g++,jdk,mysql,xlamp,python2.7,curl,go,adobe,ibus,chrome,firefox,qq,msn,openfetion,open office,msn等所以就不方便升级到12.04。P.S.我不喜欢12.04的新风格。进入正题搜索“ubuntu 升级到gcc4.7”sudo add-apt-repository ppa:ubuntu-toolchain-r/testsudo apt-g 阅读全文
posted @ 2012-12-01 23:08 junfeng_feng 阅读(1257) 评论(0) 推荐(0) 编辑
摘要: Deep Learning 介绍Deep Learning is a new area of Machine Learning research, which has been introduced with the objective of moving Machine Learning closer to one of its original goals: Artificial Intelligence.Deep Learning 动机Deep Learning --主要用于NLP(自然语言处理),可用于情感分析 --算法库(Python) --Deep Belief Networ... 阅读全文
posted @ 2012-11-24 16:41 junfeng_feng 阅读(251) 评论(0) 推荐(0) 编辑
摘要: #include<iostream>#include<cstdio>#include<cstdlib>using namespace std;class Node {public: Node* next; Node* rand; int value;};Node* copy_list_with_rand_ptr(Node* list) { if(list == NULL) { return NULL; } /* * 参考:http://hi.baidu.com/gkqofoydngbjqtq/item/6345d6104b7a8d06e... 阅读全文
posted @ 2012-11-24 16:23 junfeng_feng 阅读(325) 评论(0) 推荐(0) 编辑
摘要: 如 1,2,3,...10出现11个数字,1,2,3..11出现了13个数字。现在知道出现d个数字,求n,如果d非法,输出impossible。算法的思想是:计算n = 9, 99, 999...这些长度为1,2,3...的各个数的出现的数字个数,反推d。int calc_from_number_of_digits(int d) { if(d < 9) return d; int n = 0; int last_n = 0; int len = 1; while(d > n) { last_n = n; ... 阅读全文
posted @ 2012-11-11 23:36 junfeng_feng 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 二分查找查找key最左和最右的位置利用这个特点,可以在O(log n)时间 在排序的数组中,统计一个数出现的次数。如[1,2,2,3],2出现了两次//most_left_or_right: true 表示最左, false表示最右 int binary_search_most_left_or_right(int* array, int size, int key, bool most_left_or_right = true) { int low = 0; int high = size - 1; while(low <= high) { int mi... 阅读全文
posted @ 2012-11-11 23:28 junfeng_feng 阅读(145) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: vector<int> plusOne(vector<int> &digits) { // Start typing your C/C++ solution below // DO NOT write int main() function vector<int> result; int carray_bit = 0; digits[digits.size()-1] += 1; for(int i=digits.size()-1;i>=0;i... 阅读全文
posted @ 2012-10-09 21:31 junfeng_feng 阅读(162) 评论(0) 推荐(0) 编辑
摘要: //需要注意细节class Solution { public: string longestCommonPrefix(vector<string> &strs) { // Start typing your C/C++ solution below // DO NOT write int main() function //sort(strs.begin(),strs.end()); string result(""); if (strs.size()==0) { return r... 阅读全文
posted @ 2012-10-09 21:20 junfeng_feng 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 使用统计学的方法:O(n)分治的方法,比较复杂class Solution { public: int maxSubArray(int A[], int n) { // Start typing your C/C++ solution below // DO NOT write int main() function int maxendinghere=A[0]; int max = maxendinghere; for(int i=1;i<n;i++) { if (maxendin... 阅读全文
posted @ 2012-10-09 20:53 junfeng_feng 阅读(189) 评论(0) 推荐(0) 编辑
摘要: http://www.leetcode.com/onlinejudgeclass Solution { public: vector<string> anagrams(vector<string> &strs) { // Start typing your C/C++ solution below // DO NOT write int main() function multimap<string,string> map; for(int i=0;i<strs.size();i++) { if(s... 阅读全文
posted @ 2012-10-09 17:12 junfeng_feng 阅读(154) 评论(0) 推荐(0) 编辑
摘要: 直接使用加法/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode *addTwoNumbers(ListNode *l1, ListNode *l2) { // Start typing your C/C++ solution below ... 阅读全文
posted @ 2012-10-09 16:10 junfeng_feng 阅读(155) 评论(0) 推荐(0) 编辑