自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(63)
  • 收藏
  • 关注

原创 不同的pytorch,torchvision版本导致的key error的错误

如题,解决办法 只需要将原来版本的pytorch,torchvision卸载即可 conda list中找到pytorch,torchvision 把它们卸载,即 conda uninstall pytorch torchvision 我选择的做法是从清华源上直接下载相应版本上传到服务器自己手动安装 清华源为https://mirrors.tuna.tsinghua.edu.cn/ana...

2018-11-24 02:30:35 9003

原创 conda 安装本地包

conda install --use-local  ***.tar.bz2  

2018-11-24 02:05:41 13680

原创 Andrew Ng machine learning week2 week3作业 不用for循环 向量操作计算

例如: 计算h(x)的时候      我一开始的算法  用了几个for循环   后面发现  theta*X 可以直接得到一系列参数   累加求和的时候     求和一般转化为一个行向量乘一个列向量    向量化的关键:首先写出每一个表达式  然后再不断消除需要用到循环的字母   对于计算grad的时候  需要计算到上面这个偏导数  那么  首先h(x) 可以写成 sigmoid(th

2018-03-13 11:39:35 413

原创 ./执行python文件要加类似于#!flask/bin/python

学习flask的时候 发现 然后半天跑不了 迷醉

2018-02-18 11:01:35 581

原创 leetcode 399. Evaluate Division 并查集+图的广搜

哎 修正了好久的并查集写法 感觉做的很渣不推荐   但是打了好久 改了好久 才ac class Solution { public:          string getfather(mapstring,string> father,string x)     {         while(x!=father[x])             x

2017-12-16 18:37:58 504

原创 二叉树的moris中序遍历

空间复杂度o(1) 意味着不用栈,不用递归从而来遍历  很强  利用到了线索二叉树的算法感觉      打一下代码   可能和别的老哥帖子中代码有点像  边看边打的  void Moris(TreeNode* root)  //O(1)空间中序遍历二叉树 {     TreeNode* cur=root; //cur为当前节点     while(cur)

2017-12-07 21:24:44 245

原创 leetcode Populating Next Right Pointers in Each Node II

深搜广搜都已经打了一遍 这是不用深搜递归栈,不用广搜队列的解法      class Solution { public:     void connect(TreeLinkNode *root) {         if(!root) return;         root->next=NULL;         TreeLinkNode* cur=ro

2017-12-07 01:48:00 172

原创 几个学校作业

块链的移位 #define CHUNK_SIZE 4 /* 可由用户定义的块大小 */   /* 未存储的空间用'#'字符代替 */ typedef struct Chunk {     char ch[CHUNK_SIZE];     struct Chunk *next; }Chunk; Chunk* insert(Chunk* Shea

2017-12-04 21:09:13 448

原创 num皇后遍历

int x[9]; int sum=0; int num=8; bool place(int k) {     for(int j = 1;j         if(abs(x[k] - x[j]) == abs(k-j)||x[j] == x[k])             return false;     return true;

2017-12-04 21:03:40 179

原创 基本计算器

输入表达式字符串,以“=”表示结束, 计算并输出表达式值。 操作数可以是正负整数或实数,操作符有 “+”、“-”、“*”、“/”、“^”(乘方)和 “sin( )”(正弦)、“cos( )”(余弦)、“log( )”(对数)、“ln( )”(自然对数)等函数。 int transfer(char c) {     if(c=='+'||c=='-')  

2017-12-04 20:59:16 767

原创 Maximum Width of Binary Tree

这个题很难

2017-11-15 14:37:11 195

原创 leetcode 652. Find Duplicate Subtrees

class Solution { public:     string transfer(unordered_mapTreeNode*,string>&hash,TreeNode* root)     {         if(!root) return "#";         string l,r;             l=transfer(has

2017-11-08 11:20:41 332

原创 leetcode 691.Stickers to Spell Word

先附模仿代码 也是自己敲出来的 class Solution { public:     int helper(vectorvectorint>> map,string target,unordered_mapstring, int>&dp)     {         if (dp.count(target)) return dp[target];

2017-11-06 15:13:23 369

原创 leetcode 47. Permutations II

class Solution { public:     vectorvectorint>> res;     void dfs(vectorint> nums,vectorbool>&used,vectorint>& cur)     {         if(cur.size()==nums.size())         {          

2017-11-01 01:27:10 179

原创 leetcode Combinations

class Solution { public:     vectorvectorint>> res;     void dfs(vectorbool> &used,int t,int n,int k,int start)     {         if(t>k)         {             vectorint> re;    

2017-11-01 01:07:03 303

原创 leetcode Word Search

我的第一次代码 85/87 那aaaaa的数据没过 哎难受    后面一点点的看 优化了一下 然后 勉强ac class Solution { public:     vector> walk{{1,0},{-1,0},{0,1},{0,-1}};     bool isExist(vector> board,string word,vector> &used,int x,int y,in

2017-10-31 23:54:01 229

原创 leetcode 51. N-Queens

class Solution { public:     vectorvectorstring>> res;     int* x;     void helper(int t,int n)     {         if(t>n-1)         {             vectorstring> a;             fo

2017-10-30 17:35:28 188

原创 leetcode 696. Count Binary Substrings

class Solution { public:     int countBinarySubstrings(string s) {         int cur0=0;         int cur1=0;         int sum=0;         for(int i=0;isize()-1;i++)         {      

2017-10-29 18:22:13 227

原创 leetcode 46. Permutations

class Solution { public:     vectorint>> res;     int *x;     void helper(vectorint> nums,int t)     {         if(t>=nums.size())         {             vectorint> re;      

2017-10-29 12:01:21 242

原创 由Combination Sum I II 不懂的地方

所给num均可以重复 所有的根节点不相同,vector中不能有重复的数 void dfs(vectorint>& path,int start,vectorint> nums)     {         if(start>nums.size()-1){             //cout             res.push_back(path)

2017-10-28 12:11:15 210

原创 leetcode subsets

class Solution { public:     vectorvectorint>> res;     void dfs(vectorint>& path,int start,vectorint> nums)     {         if(start>nums.size()-1){             //cout          

2017-10-28 08:52:44 180

原创 LeetCode Combination Sum II

class Solution { public:     vectorvectorint>> res;     void dfs(int start,vectorint>&currentPath,vectorint> weight,int T)     {         if(T0)             return;         if(T=

2017-10-24 20:53:06 154

原创 基本计算器 leetcode basic calculator 顺便是老师布置的作业加了一点点功能

支持sin cos ln 的操作 只能是正数 然后其他的测试数据没测试 只在leetcode上提交ac了 leetcode224 basic calculator  class Solution { public:     int transfer(char c)     {         if(c=='+'||c=='-')             re

2017-10-22 19:46:21 298

原创 leetcode 454. 4Sum II

class Solution { public:     int fourSumCount(vectorint>& A, vectorint>& B, vectorint>& C, vectorint>& D) {         unordered_mapint, int>hash1;         unordered_mapint, int>hash2;

2017-10-22 16:43:00 144

原创 leetcode 402. Remove K Digits

class Solution { public:     string removeKdigits(string num, int k) {         if(num.size()==0)             return "";         int size=(int)num.size();         int start=0;  

2017-10-21 14:44:09 141

原创 leetcode 646. Maximum Length of Pair Chain

class Solution { public:     int findLongestChain(vectorvectorint>>& pairs) {         mapint,vectorint>> hash;         int size=(int)pairs.size();         for(int i=0;i1;i++)    

2017-10-18 16:36:30 147

原创 leetcode 316. Remove Duplicate Letters

这个题真算是打死我了,自己打了个发现算法错了 看了一些别人的博客,尝试去做了,还是不对,后面啊看到https://leetcode.com/discuss/73777/easy-to-understand-iterative-java-solution 的解答。。。 总体来说就是个思想:找到一个字母,使(他的所有左边的字母)构成的字符串 所含的字母全部都能被(它自己加上她右边)这样一个字符串

2017-10-18 13:26:28 417

原创 leetcode 503. Next Greater Element II

class Solution { public:     vectorint> nextGreaterElements(vectorint>& nums) {         vectorint> a;         if(nums.size()==0)             return a;         for(int i=0;isize()-1

2017-10-16 15:34:17 223

原创 leetcode 232.Implement Queue using Stacks

class MyQueue { private:     stackint> queue; public:     /** Initialize your data structure here. */     MyQueue() {              }     /** Push element x to the back of queue

2017-10-14 13:28:36 179

原创 leetcode.394 Decode String

class Solution { public:     string decodeString(string s) {         if(s.size()==0)             return "";         stackchar> a;         for(int i=0;isize()-1;i++)         {

2017-10-14 12:26:24 209

原创 leetcode 23. Merge k Sorted Lists

class Solution { public:     ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {         ListNode* current1=l1;         ListNode* current2=l2;         ListNode* res=new ListNode(0);

2017-10-11 10:51:10 148

原创 leetcode 148. Sort List

class Solution { public:     ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {         ListNode* current1=l1;         ListNode* current2=l2;         ListNode* res=new ListNode(0);

2017-10-11 10:31:39 157

原创 leetcode Merge Two Sorted Lists

class Solution { public:     ListNode* mergeTwoLists(ListNode* l1, ListNode* l2) {         ListNode* current1=l1;         ListNode* current2=l2;         ListNode* res=new ListNode(0);

2017-10-09 16:17:40 137

原创 leetcode 39. Combination Sum

class Solution { public:     vectorvectorint>> res;     void findPath(vectorint>& path,vectorint> candidates,int target)     {         if(target0)             return;         if

2017-10-08 16:36:53 161

原创 超时代码 01 matrix

class Solution { public:     int find0(vectorvectorint>> matrix,int x,int y)     {         vectorvectorint>> direction{{0,-1},{-1,0},{0,1},{1,0}};         int row=(int)matrix.size();

2017-10-08 14:20:30 286

原创 leetcode 92.Reverse Linked List II

class Solution { public:          ListNode* reverseList(ListNode* head) {             if(!head) return NULL;             ListNode* current=head;             ListNode* next=head->nex

2017-10-08 13:23:31 187

原创 leetcode 141. Linked List Cycle和II

看的解答,发现有快慢指针这种东西可以进行操作,又学习了一个 class Solution { public:     bool hasCycle(ListNode *head) {         ListNode* slow=head;         ListNode* fast=head;         while(slow->next&&fast-

2017-09-28 10:44:54 138

原创 leetcode Symmetric Tree

class Solution { public:     bool isSymmetric(TreeNode* root) {         if(!root) return true;         queueTreeNode*> q;         q.push(root);         while(!q.empty())        

2017-09-26 21:13:28 122

原创 leetcode 677. Map Sum Pairs

class MapSum { public:     unordered_maphash; /** Initialize your data structure here. */ MapSum() {      } void insert(string key, int val) {     hash[key]=val; } int sum(string pre

2017-09-25 15:45:32 433

原创 字典树的定义

typedef struct trie_node{         int count;         struct trie_node* next[26];         bool exist;     }TrieNode , *Trie;     TrieNode* CreatTrieNode()     {         TrieNode*

2017-09-24 16:21:48 321

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除