自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 通配符匹配

Pythonclass Solution(object): def isMatch(self, s, p): """ :type s: str :type p: str :rtype: bool """ l_s = len(s) l_p= len(p) dp =...

2020-03-30 21:36:06 190

原创 加油站

Pythonclass Solution(object): def canCompleteCircuit(self, gas, cost): """ :type gas: List[int] :type cost: List[int] :rtype: int """ sum_gas=0 ...

2020-03-29 15:21:08 197

原创 跳跃游戏

Pythonclass Solution(object): def canJump(self, nums): """ :type nums: List[int] :rtype: bool """ start = 0 end = 0 n = len(nums) w...

2020-03-28 15:53:26 187

原创 分发饼干

Pythonclass Solution(object): def findContentChildren(self, g, s): """ :type g: List[int] :type s: List[int] :rtype: int """ g.sort() s.so...

2020-03-27 21:48:07 125

原创 判断子序列

1.双指针双指针还是太慢了class Solution(object): def isSubsequence(self, s, t): """ :type s: str :type t: str :rtype: bool """ i=0 j=0 while i...

2020-03-26 21:18:10 143

原创 买卖股票的最佳时机 II

Pythonclass Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ ans = 0 for i in range(1, len(prices)): ...

2020-03-25 21:17:07 101

原创 恢复二叉搜索树

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

2020-03-24 21:35:08 106

原创 不同的二叉搜索树 II

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

2020-03-23 21:50:56 140

原创 二叉树的中序遍历

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

2020-03-22 20:34:06 136

原创 二叉树的最大深度

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

2020-03-21 11:20:56 88

原创 对称二叉树

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

2020-03-20 19:06:19 118

原创 相同的树

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

2020-03-19 18:58:02 107

原创 正则表达式匹配

Pythonclass Solution(object): def isMatch(self, s, p): len_s = len(s) len_p = len(p) res_m = [[False for j in range(len_p + 1)] for i in range(len_s + 1)] for i in...

2020-03-18 20:24:30 114

原创 最长回文子串

Python(中心扩展算法)class Solution: def longestPalindrome(self,s): if s is None and len(s) < 1:return 0 start = end = 0 for i in range(len(s)-1): len1 = self.around(s,i,i) len2 = self.aroun...

2020-03-17 19:44:41 107

原创 无重复字符的最长子串

Pythonclass Solution: def lengthOfLongestSubstring(self, s): """ :type s: str :rtype: int """ st = {} i, ans = 0, 0 for j in range(len(s)):...

2020-03-16 12:25:53 90

原创 有效的括号

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

2020-03-15 18:56:55 105

原创 最长公共前缀

Pythonclass Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ strs = list(set(strs)) if len(strs) &g...

2020-03-14 19:48:11 102

原创 罗马数字转整数

例如, 罗马数字 2 写做 II ,即为两个并列的 1。12 写做 XII ,即为 X + II 。 27 写做 XXVII, 即为 XX + V + II 。通常情况下,罗马数字中小的数字在大的数字的右边。但也存在特例,例如 4 不写做 IIII,而是 IV。数字 1 在数字 5 的左边,所表示的数等于大数 5 减小数 1 得到的数值 4 。同样地,数字 9 表示为 IX。这个特殊的规则只适...

2020-03-13 20:13:23 158

原创 合并K个排序链表

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

2020-03-12 12:09:42 102

原创 删除链表的倒数第N个节点

Python# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def removeNthFromEnd(s...

2020-03-11 15:45:26 137

原创 两数相加

Pythonclass Solution(object): def addTwoNumbers(self, l1, l2): l = ListNode(0) l_copy = l carry = 0 while l1 or l2: l1_val = l1.val if l1 else 0 ...

2020-03-10 19:42:33 197

原创 环形链表

Pythonclass Solution(object): def hasCycle(self, head): if(head == None or head.next == None): return False slow = head fast = head.next while(slow !=...

2020-03-09 11:59:30 102

原创 删除排序链表中的重复元素

Pythonclass Solution(object): def deleteDuplicates(self, head): if not (head and head.next): return head i,j = head,head while j: if i.val!=j.val: i = i.next i.val = j.val j =...

2020-03-08 12:19:41 88

原创 合并两个有序链表

class Solution(object): def mergeTwoLists(self, l1, l2): if l1 is None: return l2 elif l2 is None: return l1 elif l1.val < l2.val: l...

2020-03-07 21:32:56 82

原创 买卖股票的最佳时机 III

Pythonclass Solution: def maxProfit(self, prices): if prices==[]:return 0 length=len(prices) b1= [0 for x in prices ] s1 = prices[0] b1[0]= 0 for ...

2020-03-06 19:34:11 134

原创 最接近的三数之和

Python(双指针)class Solution(object): def threeSumClosest(self, nums, target): nums.sort() length=len(nums) flag=float("inf") for i in range(length): if i...

2020-03-05 19:28:58 111

原创 三数之和

Pythonclass Solution: def threeSum(self, nums): nums.sort() count = [] length = len(nums) for i in range(length): if i > 0 and nums[i] == nums[i-1]:...

2020-03-04 19:12:59 124

原创 移除元素

python:比较简单的直接暴力法class Solution(object): def removeElement(self, nums, val): for i in range(len(nums)-1, -1, -1): if nums[i] == val: nums.pop(i) return le...

2020-03-03 18:44:33 102

原创 删除排序数组中的重复项

Pythonclass Solution(object): def removeDuplicates(self, nums): length=len(nums) count=0 for i in range(1,length): if nums[count]!=nums[i]: nu...

2020-03-02 14:53:37 136

原创 两数之和

class Solution(object): def twoSum(self, nums, target): num_dict = {} for i, num in enumerate(nums): num_dict[i] = num for j in num_dict: if num_dict[j] == (target - num) and j != i: return [j, i]解题思...

2020-03-01 15:03:09 263

空空如也

空空如也

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

TA关注的人

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