- 博客(8)
- 收藏
- 关注
原创 Leetcode 38. 数数并说
class Solution: def countAndSay(self, n): """ :type n: int :rtype: str """ S="1" for i in range(1,n): #控制外层的迭代次数 S=self.myfun(S) ...
2018-03-31 13:55:48 935
原创 python leetcode 258. 各位相加
人生苦短,我用python我感觉我这种做法太邪恶了。。。class Solution: def addDigits(self, num): """ :type num: int :rtype: int """ num=str(num)#变成字符串来进行处理 count=0 whi...
2018-03-30 19:34:26 336
原创 leetcode 171. Excel表列序号
#思路就是26进制转10进制,这样一说是不是感觉很简单了呢?class Solution(object): def titleToNumber(self, s): """ :type s: str :rtype: int """ base=ord("A")-1 count=0 f...
2018-03-30 17:13:03 246
原创 leetcode 575. 分糖果
class Solution(object): def distributeCandies(self, candies): """ :type candies: List[int] :rtype: int """ myset=set()#表示多少种类 for i in candies: ...
2018-03-30 16:58:11 566
原创 leetcode 669. 修剪二叉搜索树
class Solution(object): def trimBST(self, root, L, R): """ :type root: TreeNode :type L: int :type R: int :rtype: TreeNode """ if root is ...
2018-03-30 09:36:43 617
原创 leetcode 806. 写字符串需要的行数
class Solution(object): def numberOfLines(self, widths, S): """ :type widths: List[int] :type S: str :rtype: List[int] """ base=ord('a') #字母a的作...
2018-03-29 19:34:36 572
原创 leetcode 657. 判断路线成圈
我用了字典的方式来做这题,挺好玩的题目class Solution: def judgeCircle(self, moves): """ :type moves: str :rtype: bool """ dict={"U":(0,1), "D":(0,-1), ...
2018-03-27 22:20:28 334
原创 leetcode 766. 托普利茨矩阵
class Solution: def isToeplitzMatrix(self, matrix): """ :type matrix: List[List[int]] :rtype: bool """ m=len(matrix) n=len(matrix[0]) for i ...
2018-03-27 20:22:54 608
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人