• 等级
  • 144063 访问
  • 264 原创
  • 31 转发
  • 13190 排名
  • 27 评论
  • 50 获赞

无法import fastText

https://github.com/facebookresearch/fastText/issues/474#issuecomment-445430211

2019-03-29 16:07:55

mac设置python版本切换,和设置python默认版本

Mac中python多版本切换$sudovi~/.bashrcshell中输入aliaspython2=’/Library/Frameworks/Python.framework/Versions/2.x/bin/python2.x’aliaspython3=’/Library/Frameworks/Python.framework/Versions/3.x/bin/...

2019-03-29 15:44:06

132. 分割回文串 II

https://leetcode-cn.com/problems/palindrome-partitioning-ii/comments/回溯(超时):classSolution:defminCut(self,s):""":types:str:rtype:int"""self.min...

2019-01-24 22:49:08

131. 分割回文串

https://leetcode-cn.com/problems/palindrome-partitioning/submissions/classSolution:defpartition(self,s):""":types:str:rtype:List[List[str]]"""s..

2019-01-23 12:27:19

130. 被围绕的区域

https://leetcode-cn.com/problems/surrounded-regions/comments/两次遍历。第一次先遍历边界,dfs将所有与边界O相连的O置为‘-’。之后再遍历所有,将所有O变为X,所有’-‘变为OclassSolution:defsolve(self,board):""":typeboard:Li...

2019-01-22 12:16:13

129. 求根到叶子节点数字之和

https://leetcode-cn.com/problems/sum-root-to-leaf-numbers/submissions/#Definitionforabinarytreenode.#classTreeNode:#def__init__(self,x):#self.val=x#self.left=...

2019-01-21 12:54:05

128. 最长连续序列

https://leetcode-cn.com/problems/longest-consecutive-sequence/用哈希表存储每个端点值对应连续区间的长度若数已在哈希表中:跳过不做处理若是新数加入:取出其左右相邻数已有的连续区间长度left和right计算当前数的区间长度为:cur_length=left+right+1根据cur_length更新最大长...

2019-01-20 13:52:14

433. 最小基因变化

https://leetcode-cn.com/problems/minimum-genetic-mutation/submissions/基本类似127题,bfsimportqueueclassSolution:defminMutation(self,start,end,bank):""":typestart:str...

2019-01-19 17:42:19

127. 单词接龙

https://leetcode-cn.com/problems/word-ladder/思路和126差不多,区别在于只用bfs,每次访问一层,用一个map来存储访问过的结点以及与起点的距离,避免重复访问。最后输出map中的终点项即可importqueueclassSolution:defladderLength(self,beginWord,endWord,wordL...

2019-01-18 16:37:24

126. 单词接龙 II

https://leetcode-cn.com/problems/word-ladder-ii/submissions/dfs+bfsimportqueueclassSolution:deffindLadders(self,beginWord,endWord,wordList):""":typebeginWord:str...

2019-01-17 18:39:12

125. 验证回文串

https://leetcode-cn.com/problems/valid-palindrome/comments/classSolution:defisPalindrome(self,s):""":types:str:rtype:bool"""#将s过滤,只保留数字和字母,再转为小...

2019-01-08 23:19:44

124. 二叉树中的最大路径和

https://leetcode-cn.com/problems/binary-tree-maximum-path-sum/submissions/对于任意一个节点,如果最大和路径包含该节点,那么只可能是两种情况:1.其左右子树中所构成的和路径值较大的那个加上该节点的值后向父节点回溯构成最大路径2.左右子树都在最大路径中,加上该节点的值构成了最终的最大路径。#Definiti...

2019-01-08 22:44:27

123. 买卖股票的最佳时机 III

https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-iii/comments/dp1[i]=max(dp[i-1],prices[i]-minval)从前往后遍历,表示第1天到第i天之间的最大利润(通过是否在第i天卖出确认);dp2[i]=max(dp[i+1],maxval-prices[i]...

2019-01-06 16:17:14

122. 买卖股票的最佳时机 II

https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/submissions/观察知,累加每两个相邻峰谷之间的差价即可classSolution(object):defmaxProfit(self,prices):""":typeprices:List[in...

2019-01-04 16:42:46

121. 买卖股票的最佳时机

https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock/solution/classSolution(object):defmaxProfit(self,prices):""":typeprices:List[int]:rtype:int...

2019-01-03 13:21:39

120. 三角形最小路径和

https://leetcode-cn.com/problems/triangle/submissions/dp,自底向上classSolution:defminimumTotal(self,triangle):""":typetriangle:List[List[int]]:rtype:int"""...

2018-12-30 23:14:51

119. 杨辉三角 II

https://leetcode-cn.com/problems/pascals-triangle-ii/classSolution:defgetRow(self,rowIndex):""":typerowIndex:int:rtype:List[int]"""res...

2018-12-28 17:55:16

118. 杨辉三角

https://leetcode-cn.com/problems/pascals-triangle/classSolution:defgenerate(self,numRows):""":typenumRows:int:rtype:List[List[int]]"""ifnumRow...

2018-12-28 17:53:08

117. 填充同一层的兄弟节点 II

https://leetcode-cn.com/problems/populating-next-right-pointers-in-each-node-ii/和116一样层序importQueueclassSolution:#@paramroot,atreelinknode#@returnnothingdefconnect(self,r...

2018-12-28 17:51:26

116. 填充同一层的兄弟节点

https://leetcode-cn.com/problems/populating-next-right-pointers-in-each-node/comments/#Definitionforbinarytreewithnextpointer.#classTreeLinkNode:#def__init__(self,x):#self...

2018-12-25 16:32:11

caisense

关注
  • 中国
奖章
  • 持之以恒