自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 503错误

503错误原因:由于临时的服务器维护或者过载,服务器当前无法处理请求。这个状况是临时的,并且将在一段时间以后恢复。日志:出现503错误,其日志都是记录在%Systemroot%\System32\LogFiles\HTTPERR\httperr1.log中。其中的s-reason项:1、若为AppShutdown,可能是由于CPU占用率太高导致自动关闭应用程序池。2、若为AppOff...

2019-09-06 16:34:50 2904 1

原创 0/1背包问题 python

0/1背包问题 python有一个包和n个物品,包的容量为m,每个物品都有各自的体积和价值,问当从这n个物品中选择多个物品放在包里而物品体积总数不超过包的容量m时,能够得到的最大价值是多少?'''测试数据:n = 6 物品的数量,c = 10 书包能承受的重量,w = [2, 2, 3, 1, 5, 2] 每个物品的重量,v = [2, 3, 1, 5, 4, 3] 每个物品的价值...

2019-09-06 16:02:03 448

原创 LeetCode56. 合并区间

LeetCode56. 合并区间Given a collection of intervals, merge all overlapping intervals.Example 1:Input: [[1,3],[2,6],[8,10],[15,18]]Output: [[1,6],[8,10],[15,18]]Explanation: Since intervals [1,3] and ...

2019-09-04 22:04:32 184

原创 python 方法和函数有什么区别?

python 方法和函数有什么区别?直接上代码:from types import FunctionType,MethodTypeclass C: def func1(self): passdef func2(): passprint("func1是函数", isinstance(C().func1, FunctionType))#Falseprint...

2019-09-04 20:55:59 318

原创 python sort(),sorted()的参数key

python sort(),sorted()的参数keyarray = [1,2,8,4,5,8,3,5,-1]#key参数,要指向一个函数,返回该计算方法得到的、排序用的权值.print(sorted(array,key=lambda x:x))#[-1, 1, 2, 3, 4, 5, 5, 8, 8]print(sorted(array,key=lambda x:-x))#[8, 8,...

2019-09-04 15:31:18 460

原创 python any() all()

python any() all()# any(x):判断 x 对象是否为空对象,如果都为空、0、false,则返回 false#如果不都为空、0、false,则返回 true#orprint(any([0,8]),any([10]))#Tureprint(any([0,None]),any(['']),any([False]),any([]))#False#all(x):如果 al...

2019-09-04 15:08:04 102

原创 Python 中递归的最大次数

Python 中递归的最大次数可以使用sys.setrecursionlimit来调整#windows10count=10000temp=[]def fun():# print(count) temp.append(1) if count>0: fun()fun()print(len(temp))#2966#RecursionErro...

2019-09-04 14:02:45 633

原创 __init__.py 有什么作用?

init.py 有什么作用?例如:一个包里有三个模块,model1.py、model2.py、model3.py,但使用 from models import *导入模块时,如何保证只有 model1、model3被导入了?在文件 init.py中增加:all = [‘model1’,‘model3’]...

2019-09-04 13:33:11 322

原创 leecode13. Roman to Integer

leecode13. Roman to Integer题目描述罗马数字包含以下七种字符: I, V, X, L,C,D 和 M。字符 数值I 1V 5X 10L 50C 100D 500M 10...

2019-09-04 10:51:08 98

原创 leetCode303 数组范围求和

leetCode303 数组范围求和题目描述:给定一个数组,求出数组范围 i 到 j (i ≤ j) 的元素总和,包含 i, j 两点。例如:给定nums = [-2, 0, 3, -5, 2, -1],?求和函数为sumRange()sumRange(0, 2) -> 1sumRange(2, 5) -> -1sumRange(0, 5) -> -3#简单,但...

2019-09-03 16:59:58 264

原创 Leetcode 121:买卖股票的最佳时机

Leetcode 121:买卖股票的最佳时机题目描述:给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。如果你最多只允许完成一笔交易(即买入和卖出一支股票),设计一个算法来计算你所能获取的最大利润。注意你不能在买入股票前卖出股票。示例 1:输入: [7,1,5,3,6,4]输出: 5解释: 在第 2 天(股票价格 = 1)的时候买入,在第 5 天(股票价格 = 6)的...

2019-09-03 16:03:29 88

原创 leetcode 53. 最大子序和

leetcode 53. 最大子序和给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。示例:输入: [-2,1,-3,4,-1,2,1,-5,4],输出: 6解释: 连续子数组 [4,-1,2,1] 的和最大,为 6class Solution: def maxSubArray(self, nums: List[int]) -...

2019-09-01 18:45:48 78

原创 LeetCode122:卖股票的最佳时机 II

LeetCode122:卖股票的最佳时机 II题目描述:给定一个数组,它的第 i 个元素是一支给定股票第 i 天的价格。设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。示例 1:输入: [7,1,5,3,6,4]输出: 7解释: 在第 2 天(股票价格 = 1)的时候买入,...

2019-09-01 18:36:48 115

转载 MAC地址

MAC地址MAC地址(英语:Media Access Control Address)也称为局域网地址(LAN Address),MAC位址,以太网地址(Ethernet Address)或物理地址(Physical Address),硬件地址。IP地址与MAC地址在计算机里都是以二进制表示的,IP地址是32位的,而MAC地址则是48位的 。MAC地址的长度为48位(6个字节),通常表示为...

2019-08-31 11:19:44 1336

原创 python ASCII码与字符相互转换

python ASCII码与字符相互转换'''ord(str)输入长度为1 的str输出 int 其ASCII码 chr(int)输入 int输出 str ASCII码对应的字符'''print(ord('a'))# 97print(chr(97))# a

2019-08-26 19:53:41 450

原创 leecode70. 爬楼梯

leecode 70. 爬楼梯题目描述:假设你正在爬楼梯。需要 n 阶你才能到达楼顶。每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢?注意:给定 n 是一个正整数。示例 1:输入: 2输出: 2解释: 有两种方法可以爬到楼顶。1 阶 + 1 阶2 阶示例 2:输入: 3输出: 3解释: 有三种方法可以爬到楼顶。1 阶 + 1 阶 + 1 阶...

2019-08-24 12:00:18 138

原创 句子的逆序

题目:对于一个字符串,请设计一个算法,只在字符串的单词间做逆序调整,也就是说,字符串由一些由空格分隔的部分组成,你需要将这些部分逆序。给定一个原字符串A和他的长度,请返回逆序后的字符串。测试样例:“dog loves pig”,13返回:“pig loves dog”# -*- coding:utf-8 -*-class Reverse: def reverseSente...

2019-08-24 11:35:44 91

原创 旋转词

题目:如果对于一个字符串A,将A的前面任意一部分挪到后边去形成的字符串称为A的旋转词。比如A=“12345”,A的旋转词有"12345",“23451”,“34512”,“45123"和"51234”。对于两个字符串A和B,请判断A和B是否互为旋转词。给定两个字符串A和B及他们的长度lena,lenb,请返回一个bool值,代表他们是否互为旋转词。测试样例:“cdab”,4,“abcd”,...

2019-08-24 11:06:53 433

原创 np.newaxis

np.newaxis可以给数组加一维import numpy as npdata = np.array([range(9),range(9,18)])print(data) # shape (2,9)#[[ 0 1 2 3 4 5 6 7 8]# [ 9 10 11 12 13 14 15 16 17]]print(data[:,:,np.newaxis]) # ...

2019-08-22 15:02:00 111

原创 python * **

# -*- coding: utf-8 -*-"""# *可以用来解包#这里还不知道args是什么,就加前缀,那args就作为一个整体#即args是一个可解包的变量,再加上不可修改,那就是一个元组了!!def F1(*args): print(args)F1(123,"456")# (123, '456')#** 姑且看作两次解包,那么需要进行两次解包的数据结构,只...

2019-08-22 00:32:21 266

原创 MSL(Maximum Segment Lifetime)报文最大生存时间

MSL(Maximum Segment Lifetime)报文最大生存时间Windows:MSL=2 minlinux(Ubuntu,CentOs):MSL=60sUnix:MSL=30s

2019-08-20 09:49:03 11272 1

原创 pandas 读csv文件,报错:ParserError:Error tokenizing data.

pandas 读csv文件,报错:ParserError: Error tokenizing data. C error: Buffer overflow caught - possible malformed input file.解决方法1:如果使用python及其大文件,可以使用 engine=‘python’解决方法2:原因是pandas用作行终止符的数据中有一些回车符“\ r...

2019-08-15 12:31:01 3127

原创 leecode108. Convert Sorted Array to Binary Search Tree有序数组转化为二叉搜索树

leecode108. Convert Sorted Array to Binary Search Tree有序数组转化为二叉搜索树Example:Given the sorted array: [-10,-3,0,5,9],One possible answer is: [0,-3,9,-10,null,5], which represents the following height...

2019-07-07 17:49:17 140

原创 leecode107. Binary Tree Level Order Traversal II二叉树层次遍历 自底向上

leecode107. Binary Tree Level Order Traversal II二叉树层次遍历 自底向上For example:Given binary tree [3,9,20,null,null,15,7],*** 3*** / \** 9 20**** / \** 15 7return its bottom-up level or...

2019-07-07 17:12:24 108

原创 leecode106. Construct Binary Tree from Inorder and Postorder Traversal中序后序重建树

leecode106. Construct Binary Tree from Inorder and Postorder Traversal中序后序重建树For example, giveninorder = [9,3,15,20,7]postorder = [9,15,7,20,3]Return the following binary tree:*** 3*** / \...

2019-07-07 16:53:52 94

原创 leecode105. Construct Binary Tree from Preorder and Inorder Traversal先序中序重建树

leecode105. Construct Binary Tree from Preorder and Inorder Traversal先序中序重建树For example, givenpreorder = [3,9,20,15,7]inorder = [9,3,15,20,7]Return the following binary tree:3/ \9 20** / ...

2019-07-07 16:06:56 94

原创 leecode104. Maximum Depth of Binary Tree树高

leecode104. Maximum Depth of Binary Tree树高Example:Given binary tree [3,9,20,null,null,15,7],*** 3*** / \** 9 20**** / \** 15 7return its depth = 3.#迭代class Solution: def maxDep...

2019-07-07 15:07:51 104

原创 leecode10. Regular Expression Matching字符串匹配

leecode10. Regular Expression Matching字符串匹配‘.’ Matches any single character.‘*’ Matches zero or more of the preceding element.Example 1:Input:s = “aa”p = “a”Output: falseExplanation: “a” does ...

2019-07-06 23:50:54 140

原创 leecode103. Binary Tree Zigzag Level Order Traversal二叉树 之字形 层次遍历

Binary Tree Zigzag Level Order TraversalFor example:Given binary tree [3,9,20,null,null,15,7],3/ \9 20** / \15 7return its zigzag level order traversal as:[[3],[20,9],[15,7]]class...

2019-07-06 19:18:25 138

原创 leecode102. Binary Tree Level Order Traversal二叉树层次遍历

leecode102. Binary Tree Level Order Traversal二叉树层次遍历For example:Given binary tree [3,9,20,null,null,15,7],3/ \9 20** / \*15 7return its level order traversal as:[[3],[9,20],[15,7]]# ...

2019-07-06 18:09:51 237

原创 leecode 101. Symmetric Tree对称树

leecode 101. Symmetric Tree对称树For example, this binary tree [1,2,2,3,4,4,3] is symmetric:***1** / \** 2 2** / \ / \*3 4 4 3But the following [1,2,2,null,3,null,3] is not:1/ \2 2\ ...

2019-07-06 17:51:04 132

原创 leecode 100. Same Tree

Same TreeExample 1:Input: 1 1------- / \ / \*****2 3 2 3 [1,2,3], [1,2,3]Output: trueExample 2:Input: 1 ***1------- / \ ** / \******2 ...

2019-07-06 17:30:16 89

原创 leecode98. Validate Binary Search Tree验证搜索二叉树

Example 1:2/ \1 3Input: [2,1,3]Output: trueExample 2:5/ \1 4– / \*3 6Input: [5,1,4,null,null,3,6]Output: false# Definition for a binary tree node.# class TreeNode:# def _...

2019-07-06 16:33:51 97

原创 快排python 递归和迭代

quick_sort = lambda array: array if len(array) <= 1 else quick_sort([item for item in array[1:] if item <= array[0]]) + [array[0]] + + quick_sort([item for item in array[1:] if item > ar...

2019-07-06 16:02:19 158

原创 leecode 5. Longest Palindromic Substring最长回文子串

leecode 5. Longest Palindromic Substring最长回文子串Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example 1:Input: “babad”Output: “ba...

2019-06-30 15:19:06 150

原创 leecode 11. Container With Most Water

Container With Most WaterGiven n non-negative integers a1, a2, …, an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i...

2019-06-30 12:06:54 122

原创 leecode 94. 二叉树的中序遍历

leecode 94. 二叉树的中序遍历94. Binary Tree Inorder TraversalExample:Input: [1,null,2,3]1\ 2/3Output: [1,3,2]# Definition for a binary tree node.# class TreeNode:# def __init__(self, x):# ...

2019-06-29 15:38:07 135

原创 leecode 94. 二叉树的中序遍历 144. 二叉树的前序遍历 145. 二叉树的后序遍历

94. 二叉树的中序遍历题目描述给定一个二叉树,返回它的中序 遍历。示例:输入: [1,null,2,3]1\2/3输出: [1,3,2]144. 二叉树的前序遍历题目描述给定一个二叉树,返回它的 前序 遍历。示例:输入: [1,null,2,3]1\2/3输出: [1,2,3]二叉树的后序遍历题目描述给定一个二叉树,返回它的 后序 遍历。示例...

2019-06-08 20:04:29 161

原创 leecode53. 最大子序和

53. 最大子序和题目描述给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。示例:输入: [-2,1,-3,4,-1,2,1,-5,4],输出: 6解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。class Solution: def maxSubArray(self, nums: List[int]) -&gt...

2019-06-08 19:05:49 92

原创 leecode44. 通配符匹配

44. 通配符匹配题目描述给定一个字符串 (s) 和一个字符模式 § ,实现一个支持 ‘?’ 和 ‘*’ 的通配符匹配。‘?’ 可以匹配任何单个字符。‘*’ 可以匹配任意字符串(包括空字符串)。两个字符串完全匹配才算匹配成功。说明:s 可能为空,且只包含从 a-z 的小写字母。p 可能为空,且只包含从 a-z 的小写字母,以及字符 ? 和 *。示例 1:输入:s = “aa”...

2019-06-08 17:38:10 228

空空如也

空空如也

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

TA关注的人

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