原创 MFC程序的誕生過程

第6章 MFC程序的生死因果的一個分析 以下是對第6章 MFC程序的生死因果的一個分析 大致過程如下: 1  產生一個全局變量CMyWinApp對象theApp,在hello.cpp中。 2  進入AfxWinMain 3  Af

原创 Leetcode:Distinct Subsequences

動態規劃: dp[i][j] 表示最優子結構。 if(S[i] == T[j])      dp[i][j] = dp[i-1][j-1] ;//S[i-1]能組成多少種T[j-1]; else     dp[i][j] =1; dp[i

原创 LeetCode:Minimum Depth of Binary Tree

寬搜 class Solution { public: int minDepth(TreeNode *root) { // Start typing your C/C++ solution below

原创 編程之美 數組分割

問題1: 有一個無序、元素個數爲n的正整數數組,要求:如何能把這個數組分割爲兩個子數組,子數組的元素個數不限,並使兩個子數組之和最接近。 解答: int sum = 0; for (i=0; i<n; i++)

原创 LeetCode:Populating Next Right Pointers in Each Node I,II 編程之美3.10

解答:         隊列實現按排遍歷 class Solution { public: struct InvoLevelNode { TreeLinkNode *node; int level; InvoL

原创 LeetCode:Convert Sorted List to Binary Search Tree

尋找中間位置作爲根節點,把根節點前面部分最後一個節點的next置爲NULLclass Solution { public: TreeNode * sortList(ListNode *node) { if(nod

原创 Leetcode:Symmetric Tree

解題思路:根節點左子樹做個旋轉則爲右子樹(旋轉是指所有節點左右孩子進行調換)                    則每次判斷左子樹下每個位置節點是否與右子樹相對應位置相同。 class Solution { public: b

原创 hapter 1: Setting the Stage

關鍵詞:factory pattern , Dependency Injection(DI), Guice(pronounced “juice” ) 參考: 【1】維基DI :http://en.wikipedia.org/wiki/De

原创 how to install scikit-learn

Enviroment:        system platform : OS 10.8.5Python:2.7The first method I've tried : failed  using  MacPorts : " It ca

原创 1163 訪問藝術館

#include<iostream> #include<stack> #include<cstring> using namespace std; #define num 700 int tree[num]; int dp[num][nu

原创 How to find out suitable parameters using cross validation

problem description: Suppose we have a model with one or more unknown parameters, and a data set to which the model c

原创 LeetCode:Permutation Sequence

我首先用vector進行保存,全部便利一遍,結果TLE了,不過遍歷代碼還是有參考價值的。 class Solution { public: vector<string> result; void search(int index,int

原创 cuda編程------矩陣乘法

cuda + VS 2010 安裝:http://www.cnblogs.com/xing901022/archive/2013/08/09/3248469.html 本文主要介紹如何使用CUDA並行計算矩陣乘法: //頭文件 #inc

原创 Leetcode:Length of Last Word

考慮沒周全 class Solution { public: int lengthOfLastWord(const char *s) { // Start typing your C/C++ solution be

原创 Leetcode:Largest Rectangle in Histogram

尋找直方圖最大面積 對於 index=i 往左尋找第一個比i低的直方圖p 往右尋找第一個比i低的直方圖q 則以height[i]爲高度的面積爲 (q-p+1)*height[i]; 直接遍歷 超時了,可以用使用dp 新建兩個數組 left