自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 我的算法之路48--字符串的排列

# -*- coding:utf-8 -*-class Solution: def Permutation(self, ss): # write code here if not ss: return [] ss=list(ss) l=[] stt='' self.dp...

2019-06-13 17:12:28 190

原创 我的算法之路49--二叉搜索树与双向链表

# -*- coding:utf-8 -*-# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution: def Convert(self, pRootOfTree):...

2019-06-13 16:21:27 134

原创 我的算法之路48--复杂链表的复制

# -*- coding:utf-8 -*-# class RandomListNode:# def __init__(self, x):# self.label = x# self.next = None# self.random = Noneclass Solution: # 返回 RandomListNode ...

2019-06-12 16:27:49 161

原创 我的算法之路47--二叉树中和为某一值的路径

# -*- coding:utf-8 -*-# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution: # 返回二维列表,内部每个列表表示找到的路径 def F...

2019-06-12 12:14:49 132

原创 我的算法之路46--二叉搜索树的后序遍历序列

# -*- coding:utf-8 -*-class Solution: def VerifySquenceOfBST(self, sequence): # write code here length = len(sequence) if length == 0: return False if ...

2019-06-12 11:47:45 103

原创 我的算法之路45--栈的压入、弹出序列

# -*- coding:utf-8 -*-class Solution: def IsPopOrder(self, pushV, popV): # write code here stack=[] index=0 while index<len(popV): if popV[index] no...

2019-06-11 20:46:25 103

原创 我的算法之路44--包含min函数的栈

class Solution: def __init__(self): self.stack=[] self.minstack=[] def push(self, node): # write code here self.stack.append(node) if not self.minstack ...

2019-06-11 20:28:43 83

原创 我的算法之路43--顺时针打印矩阵

# -*- coding:utf-8 -*-class Solution: # matrix类型为二维列表,需要返回列表 def printMatrix(self, matrix): # write code here res=[] while matrix: res+=matrix.pop(0) ...

2019-06-11 17:40:44 106

原创 我的算法之路42--链表中环的入口结点

# -*- coding:utf-8 -*-# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def EntryNodeOfLoop(self, pHead): # write code here...

2019-06-11 12:42:33 163

原创 我的算法之路41--表示数值的字符串

# -*- coding:utf-8 -*-class Solution: # s字符串 def isNumeric(self, s): # write code here if not s: return False i=0 if s[i] in ['+','-']: ...

2019-06-11 11:43:37 85

原创 我的算法之路40--正则表达式匹配

# -*- coding:utf-8 -*-class Solution: # s, pattern都是字符串 def match(self, s, pattern): # write code here if not s and not pattern: return True if s and not p...

2019-06-11 10:54:49 117

原创 我的算法之路39--删除链表中重复的结点

-*- coding:utf-8 -*-# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def deleteDuplication(self, pHead): # write code here...

2019-06-06 12:19:01 100

原创 我的算法之路38--钥匙和房间

class Solution: def canVisitAllRooms(self, rooms: List[List[int]]) -> bool: h_room=set() h_room.add(0) visited=[] for k in range(len(rooms[0])): self...

2019-05-31 14:52:01 183

原创 我的算法之路37--01 矩阵

class Solution: def updateMatrix(self, matrix: List[List[int]]) -> List[List[int]]: stack=[] cor=[[1,0],[0,1],[-1,0],[0,-1]] for r in range(len(matrix)): for...

2019-05-31 14:11:16 130

原创 我的算法之路36--图像渲染

class Solution: def floodFill(self, image: List[List[int]], sr: int, sc: int, newColor: int) -> List[List[int]]: visited=[] pre=image[sr][sc] self.dp(image,sr,sc,newColo...

2019-05-31 11:01:44 607

原创 我的算法之路35--字符串解码

class Solution: def decodeString(self, s: str) -> str: l=[0] return self.dp(s,l) def dp(self,s,l): res='' n=len(s) while(l[0]<n and s[l[0]]!=...

2019-05-30 17:05:05 219

原创 我的算法之路34--用队列实现栈

class MyStack: def __init__(self): """ Initialize your data structure here. """ self.l1=[] self.l2=[] def push(self, x: int) -> None: """...

2019-05-29 16:19:52 191

原创 我的算法之路33--用栈实现队列

class MyQueue: def __init__(self): """ Initialize your data structure here. """ self.l1=[] self.l2=[] def push(self, x: int) -> None: """...

2019-05-29 16:01:11 84

原创 我的算法之路32--机器人的运动范围

# -*- coding:utf-8 -*-class Solution: def movingCount(self, threshold, rows, cols): # write code here if rows<1 or cols<1 or threshold<0: return 0 vis...

2019-05-27 19:02:14 136

原创 我的算法之路31--矩阵中的路径

# -*- coding:utf-8 -*-class Solution: def hasPath(self, matrix, rows, cols, path): # write code here visited=[False for i in range(rows*cols)] if not matrix or rows<1 ...

2019-05-27 17:52:30 85

原创 我的算法之路30--对称的二叉树

# -*- coding:utf-8 -*-# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution: def isSymmetrical(self, pRoot):...

2019-05-27 15:28:21 77

原创 我的算法之路29--二叉树的下一个结点

# -*- coding:utf-8 -*-# class TreeLinkNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = None# self.next = Noneclass Solution: d...

2019-05-27 15:18:09 71

原创 我的算法之路28--目标和

class Solution: def findTargetSumWays(self, nums, S): """ :type nums: List[int] :type S: int :rtype: int """ sum_nums = sum(nums) if sum_num...

2019-05-23 18:05:56 214

原创 我的算法之路28--克隆图

"""# Definition for a Node.class Node: def __init__(self, val, neighbors): self.val = val self.neighbors = neighbors"""class Solution: def cloneGraph(self, node: 'Node') -&...

2019-05-22 20:15:45 215

原创 我的算法之路27--树的子结构

# -*- coding:utf-8 -*-# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution: def HasSubtree(self, pRoot1, pR...

2019-05-20 11:10:56 70

原创 我的算法之路26--每日温度

class Solution(object): def dailyTemperatures(self, T): """ :type T: List[int] :rtype: List[int] """ stack=[] result=[0 for i in range(len(T))] ...

2019-05-14 15:56:07 249

原创 我的算法之路25--有效的括号

class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ left=[u'[',u'{',u'('] right=[u']',u'}',u')'] s=list(s) ...

2019-05-14 14:51:24 60

原创 我的算法之路24--完全平方数

class Solution(object): def numSquares(self, n): """ :type n: int :rtype: int """ count=0 res=[n] while 0 not in res: count+=1...

2019-05-14 11:34:16 530

原创 我的算法之路23--缺失数字

class Solution: def missingNumber(self, nums: List[int]) -> int: l=len(nums) for i in range(len(nums)): l+=(i-nums[i]) return l

2019-04-23 20:30:38 131

原创 我的算法之路22-- 帕斯卡三角形

class Solution(object): def generate(self, numRows): """ :type numRows: int :rtype: List[List[int]] """ if not numRows: return [] ln=[[1...

2019-04-23 19:00:22 197

原创 我的算法之路21--颠倒二进制位

class Solution: # @param n, an integer # @return an integer def reverseBits(self, n): m=0 for i in range(32): m=m<<1 m=m|(n&1) ...

2019-04-23 18:48:51 92

原创 我的算法之路20--位1的个数

class Solution(object): def hammingWeight(self, n): """ :type n: int :rtype: int """ cont=0 while(n>0): cont+=1 n=(n-1)&a...

2019-04-23 18:28:05 100

原创 我的算法之路19-- Shuffle an Array

class Solution: def __init__(self, nums: List[int]): self.nums=nums def reset(self) -> List[int]: """ Resets the array to its original configuration and return it....

2019-04-23 17:12:52 70

原创 我的算法之路18--报数

class Solution: def countAndSay(self, n: int) -> str: s="1" for i in range(n-1): ss='' ls=[] for j in range(len(s)): if not l...

2019-04-23 13:06:41 120

原创 我的算法之路17--字符串中的第一个唯一字符

class Solution(object): def firstUniqChar(self, s): """ :type s: str :rtype: int """ flag=set() for i in range(0,len(s)): if s[i] in fla...

2019-04-23 11:50:33 65

原创 我的算法之路16-- 整数反转

class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ if x>=0: f=1 else: f=-1 x=x*f ...

2019-04-23 11:24:58 79

原创 我的算法之路15--旋转图像

class Solution(object): def rotate(self, matrix): """ :type matrix: List[List[int]] :rtype: None Do not return anything, modify matrix in-place instead. """ ...

2019-04-23 11:03:25 288

原创 我的算法之路14-- 只出现一次的数字

给定一个非空整数数组,除了某个元素只出现一次以外,其余每个元素均出现两次。找出那个只出现了一次的元素。说明:你的算法应该具有线性时间复杂度。 你可以不使用额外空间来实现吗?示例 1:输入: [2,2,1]输出: 1示例2:输入: [4,1,2,1,2]输出: 4class Solution: def singleNumber(self, nums: ...

2019-04-21 16:26:17 92

原创 我的算法之路13-- 合并K个排序链表

# Definition for singly-linked list.# class ListNode:# def __init__(self, x):# self.val = x# self.next = Noneclass Solution: def mergeKLists(self, lists: List[ListNode]) ...

2019-04-18 13:14:28 111

原创 我的算法之路12--将有序数组转换为二叉搜索树

# Definition for a binary tree node.# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = Noneclass Solution: def sortedArrayTo...

2019-04-17 22:47:43 91

空空如也

空空如也

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

TA关注的人

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