自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

转载 如何理解Python中的元类metaclass

以下理解整理翻译自Stackoverflow-What are metaclasses in Python?关于这个已经有博主翻译转载过了,深刻理解Python中的元类(metaclass)1、Python中的类在理解元类之前,你需要掌握Python中的类。Python中借用了SmallTalk语言特性对类进行实现。在大部分的语言中,类一般是一段生成对象的代码,这在...

2019-02-13 11:55:00 121

转载 Mysql命令学习

1. CREATE DATABASE dbname;2. DROP DATABASE dbname;3. GRANT ALL PRIVILEGES ON dbname.* TO 'username'@'localhost' IDENTIFIED BY 'usercode';4. USE dbname;5. CREATE TABLE tablename (name type...

2018-11-09 10:54:00 74

转载 Leetcode刷题记录_20181101

257.Binary Tree Paths深度优先遍历 1 class Solution: 2 def binaryTreePaths(self, root): 3 """ 4 :type root: TreeNode 5 :rtype: List[str] 6 """ 7...

2018-11-01 19:16:00 67

转载 Leetcode刷题记录_20181030

303.Range Sum Query - Immutable使用类的方法,求下标i-j之和。在初始化中处理数据可以节省大量时间。 1 class NumArray: 2 3 def __init__(self, nums): 4 """ 5 :type nums: List[int] 6 ...

2018-10-30 19:31:00 88

转载 Leetcode刷题记录_20181029

235.Lowest Common Ancestor of a Binary Search Tree在一个二叉搜索树中找两个节点的最小公共父节点。使用二叉搜索树的性质,设x是二叉搜索树中的一个结点。如果y是x左子树中的一个结点,那么会有y.key<=x.key;如果y是x右子树中的一个节点,那么有y.key>=x.keyhttps://blog.csdn.net...

2018-10-29 18:20:00 95

转载 Leetcode刷题记录_20181028

225.Implement Stack using Queues实现栈的操作方法。通过列表方法实现。 1 class MyStack(object): 2 3 def __init__(self): 4 """ 5 Initialize your data structure here. 6 ...

2018-10-28 23:48:00 74

转载 Leetcode刷题记录_20181027

205.Isomorphic Strings判断两个字符串的是否同形。利用字典,字符串中每一个不同的字符对应一个数字,最后数字相同则表示字符串同形。更简单的办法:判断len(set(s)) len(set(t)) len(set(zip(s,t))) 是否相等 1 class Solution(object): 2 def isIsomorphic(...

2018-10-27 22:51:00 56

转载 Leetcode刷题记录_20181026

202.Happy Number最终平方和为1则为快乐肥宅数!循环过程中可建立一个数组,存储中间结果。 1 class Solution(object): 2 def isHappy(self, n): 3 """ 4 :type n: int 5 :rtype: bool 6 ...

2018-10-26 19:47:00 49

转载 Leetcode刷题记录_20181025

190.Reverse Bits先转化为2进制,取[2:](排除0b),转换成列表,填充0,join,int转换 1 class Solution: 2 # @param n, an integer 3 # @return an integer 4 def reverseBits(self, n): 5 m = ...

2018-10-25 19:00:00 75

转载 Leetcode刷题记录_20181024

169.Majority Element建立字典,统计数字数目,满足要求的输出。 1 class Solution(object): 2 def majorityElement(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 ...

2018-10-24 21:00:00 57

转载 Leetcode刷题记录_20181023

160.Intersection of Two Linked Lists查找并返回AB链表中的交点,若无返回None方法1:计算A、B两个链表长度,优先循环长度长的链表,长度差次循环后,依次对比AB 1 class Solution(object): 2 def getIntersectionNode(self, headA, headB): 3 ...

2018-10-23 22:40:00 63

转载 Leetcode刷题记录-20181022

136.Single Number方法一:建立字典,依次循环; 1 class Solution: 2 def singleNumber(self, nums): 3 """ 4 :type nums: List[int] 5 :rtype: int 6 """ 7 ...

2018-10-22 17:48:00 60

转载 LeetCode刷题记录-20181021

119.Pascal's Triangle II返回杨辉三角第n层数字列表,和118类似 1 class Solution: 2 def getRow(self, rowIndex): 3 """ 4 :type rowIndex: int 5 :rtype: List[int] 6 ...

2018-10-21 19:02:00 69

转载 Leetcode刷题记录-20181020

111.Minimum Depth of Binary Tree给定一个二叉树,求其最小深度如果没有根节点,返回0;如果有根节点,判断左右孩子,有左孩子,返回 左孩子最小深度+1;有右孩子,返回右孩子最小深度+1;左右孩子都有,返回左右孩子最小深度+1;都没有,返回1 1 class Solution: 2 def minDepth(self, root)...

2018-10-20 16:30:00 58

转载 Leetcode刷题记录-20181019

107.Binary Tree Level Order Traversal II将二叉树按层转化成列表,自底向上排列按照每层进行处理,当层数据转化为列表a,下层节点存入列表b;每层处理完,处理列表b;最后反转列表。 1 class Solution: 2 def levelOrderBottom(self, root): 3 ""...

2018-10-19 16:41:00 59

转载 Leetcode刷题记录-20181018

Tree操作# Definition for a binary tree node.# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.right = None100.Same Tree递归,注意判断条件,...

2018-10-18 16:48:00 49

转载 Leetcode刷题记录-20181017

38.Count and Say递归算法 1 class Solution: 2 def handleN(self,l): 3 key = '' 4 tag = 0 5 result = '' 6 7 key = l[0] 8 ...

2018-10-16 17:22:00 59

转载 Leetcode- 初级数组

1 、从排序数组中删除重复项给定一个排序数组,你需要在原地删除重复出现的元素,使得每个元素只出现一次,返回移除后数组的新长度。不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。备注:是一个排序数组1 class Solution:2 def removeDuplicates(self,nums):3 ...

2018-05-08 23:28:00 53

空空如也

空空如也

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

TA关注的人

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