- 博客(30)
- 资源 (9)
- 收藏
- 关注
原创 133. Clone Graph
class Solution {private: unordered_map<int,UndirectedGraphNode*> m; UndirectedGraphNode *clone(UndirectedGraphNode *node) { if(m.find(node->label)!=m.end())return m[node->label];
2016-09-30 16:08:00 346
原创 neural network -recognize handwritten digits
"""network.py~~~~~~~~~~A module to implement the stochastic gradient descent learningalgorithm for a feedforward neural network. Gradients are calculatedusing backpropagation. Note that I have f
2016-09-25 22:27:52 471
原创 130. Surrounded Regions
class Solution {private: void check(vector<vector<char>>&board,int i,int j,int row,int col) { if(board[i][j]=='O') { board[i][j]='1'; if(i>1)
2016-09-19 14:43:12 313
原创 127. Word Ladder 2
class Solution {public: int ladderLength(string beginWord, string endWord, unordered_set<string>& wordList) { int dist=2; unordered_set<string> head,tail,*phead,*ptail; hea
2016-09-19 10:39:03 468
原创 neural_network
import numpy as np%matplotlib inlineimport matplotlib.pyplot as pltN = 100 # number of points per classD = 2 # dimensionalityK = 3 # number of classesX = np.zeros((N*K,D)) # data matrix (each row
2016-09-18 22:44:18 522
原创 softmax_linear_classifier
import numpy as np%matplotlib inlineimport matplotlib.pyplot as pltN = 100 # number of points per classD = 2 # dimensionalityK = 3 # number of classesX = np.zeros((N*K,D)) # data matrix (each row
2016-09-18 22:43:34 1693
原创 127. Word Ladder
class Solution {private: void nextWords(string word,unordered_set<string>& wordList,queue<string> &tovisit)//在wordList中寻找和word 只相差一个字母的单词添加到tovisit中 并从wordList 中删除word { wordList.erase
2016-09-18 10:38:15 315
原创 119. Pascal's Triangle II
class Solution { public: vector getRow(int rowIndex) { if(rowIndex==0) { vector temp(1,1); return temp; } else if(rowIndex==1)
2016-09-17 22:43:47 228
原创 118. Pascal's Triangle
class Solution {public: vector<vector<int>> generate(int numRows) { vector<vector<int>> result; for(int i=1;i<=numRows;i++) { if(i==1) {
2016-09-17 22:16:58 264
原创 109. Convert Sorted List to Binary Search Tree
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; *//** * Definition for a binary tree node.
2016-09-14 10:29:45 239
原创 57. Insert Interval
class Solution {public: static bool myfunction(Interval a,Interval b) { return a.start<b.start; } vector<Interval> insert(vector<Interval>& intervals, Interval newInterval) {
2016-09-13 11:28:03 234
原创 65. Valid Number
class Solution {public: bool isNumber(string s) { int i=0; int n=s.length(); while(i<n&&s[i]==' ')i++;//去除刚开始的空格 if(i<n&&(s[i]=='-'||s[i]=='+'))i++;//去除正负号
2016-09-13 09:48:33 300
原创 56. Merge Intervals
/** * Definition for an interval. * struct Interval { * int start; * int end; * Interval() : start(0), end(0) {} * Interval(int s, int e) : start(s), end(e) {} * }; */class Sol
2016-09-12 14:19:10 290
原创 29. Divide Two Integers
class Solution {public: int divide(int dividend, int divisor) { if(divisor==0||(dividend==INT_MIN&&divisor==-1)) return INT_MAX; int sign=(dividend<0^divisor<0)?-1:1;
2016-09-12 10:46:52 242
原创 12. Integer to Roman
class Solution {public: string intToRoman(int num) { string M[] = {"", "M", "MM", "MMM"}; string C[] = {"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", "CM"}; string X[] = {"", "
2016-09-11 09:24:10 235
原创 2. Add Two Numbers
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */class Solution {public: ListNode* add
2016-09-10 15:27:00 342
原创 101. Symmetric Tree
/** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */class
2016-09-10 14:45:22 319
原创 backpropagation
1.关于梯度简单的理解f(x,y)=xy 可以很容易得到f(x,y)关于x 和y的偏导数 函数关于每个变量的偏导数告诉了你整个函数对于单个变量的敏感程度。2.链式法则f(x,y,z)=(x+y)z 可以把上面的公式分解成为 q=x+y 和 f=qz 对y求偏导也同样如此 # set some inputs x = -2; y = 5; z = -
2016-09-08 10:33:36 457
原创 python urlretrieve
from urllib.request import urlretrievedef cbk(a,b,c): ''' report function a:the number of data block b:the size of data block c:the total size of data ''' per=100.0*a*b/c
2016-09-07 16:17:27 366
原创 logistic_regression
import numpyimport theanoimport theano.tensor as Trng = numpy.randomN = 400 # training sample sizefeats = 784 # number of input varia
2016-09-07 11:33:04 1107
原创 DigitRecognizer
from sklearn.ensemble import RandomForestClassifierimport numpy as npimport pandas as pddataset=pd.read_csv('input/train.csv')test=pd.read_csv('input/test.csv')dataset.describe()
2016-09-06 19:01:53 628
原创 8. String to Integer (atoi)
class Solution {public: int myAtoi(string str) { int sign=1; int result=0; int i=0; while(str[i]==' ') { i++; } if(str[i]=='-')
2016-09-06 14:01:26 331
原创 7. Reverse Integer
class Solution { public: int reverse(int x) { int result=0; while(x!=0) { int tail=x%10; x/=10; int temp=result*10+tail; if((temp-tail)/1
2016-09-06 09:52:59 248
原创 14. Longest Common Prefix
class Solution {public: string longestCommonPrefix(vector<string>& strs) { if(strs.size()==0) { string empty; return empty; }
2016-09-05 22:57:35 276
原创 17. Letter Combinations of a Phone Number
class Solution {private: void solve(vector<string> &result,string &cur,int level,vector<vector<char>> table,string &digits) { if(level==digits.length()) { result.pu
2016-09-03 14:53:37 322
原创 52. N-Queens II
class Solution {private: int total=0; void solve(vector<string> &cur,int row,int n) { if(row==n) { total++; return; } else {
2016-09-02 16:42:57 293
原创 51. N-Queens
class Solution {private: void solve(vector<vector<string>> &result, vector<string> &cur,int row,int n) { if(row==n) { result.push_back(cur); } else
2016-09-02 13:26:34 407
原创 digit_recongnition
# Standard scientific Python imports%matplotlib inlineimport matplotlib.pyplot as plt# Import datasets, classifiers and performance metricsfrom sklearn import datasets, svm, metrics# The digits data
2016-09-01 16:23:15 786
原创 37. Sudoku Solver
class Solution {private: bool sove(vector<vector<char>>&board) { for(int i=0;i<board.size();i++) { for(int j=0;j<board[0].size();j++) {
2016-09-01 14:47:32 342
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人