![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
Flying fish32
这个作者很懒,什么都没留下…
展开
-
Python3常用语句及用法介绍(三)——循环语句
1.while循环①while②while True2.for循环①for遍历序列②并行迭代③break3.列表推导式①单个元素②多个元素未完待续……原创 2018-11-04 17:03:18 · 320 阅读 · 0 评论 -
leetcode182. 查找重复的电子邮箱
方法1.直接法思路: 用group by Email 分组后,数据个数大于1的就是重复的# Write your MySQL query statement belowSelect Email from Person group by Email having count(Email) > 1...原创 2019-10-04 20:19:51 · 199 阅读 · 0 评论 -
leetcode175. 组合两个表
方法1.直接法# Write your MySQL query statement belowselect FirstName, LastName, City, Statefrom Person left join Addresson Person.PersonId = Address.PersonId原创 2019-10-04 20:09:23 · 92 阅读 · 0 评论 -
leetcode172. 阶乘后的零
解法1: 递归法思路: 0的个数为因子中5的个数class Solution(object): def trailingZeroes(self, n): """ :type n: int :rtype: int """ if n < 5: return 0 r...原创 2019-09-22 21:02:44 · 79 阅读 · 0 评论 -
leetcode168. Excel表列名称
给定一个正整数,返回它在 Excel 表中相对应的列名称。例如,解法1: 直接转换法思路: 运用ASCII码转换函数chr进行转换class Solution(object): def convertToTitle(self, n): """ :type n: int :rtype: str """ ...原创 2019-09-22 20:57:17 · 72 阅读 · 0 评论 -
leetcode167. 两数之和 II - 输入有序数组
给定一个已按照升序排列 的有序数组,找到两个数使得它们相加之和等于目标数。函数应该返回这两个下标值 index1 和 index2,其中 index1 必须小于 index2。说明:返回的下标值(index1 和 index2)不是从零开始的。你可以假设每个输入只对应唯一的答案,而且你不可以重复使用相同的元素。解法1: 双指针夹逼法 / 对撞指针法思路: 两个指针分别从最左和最右向...原创 2019-09-22 20:40:31 · 91 阅读 · 0 评论 -
leetcode160. 相交链表
编写一个程序,找到两个单链表相交的起始节点。如下面的两个链表:解法1.双指针法思路: 两个指针分别从两个head开始,直至达到末尾,然后从另一个head开始,当两指针相遇,即为相交节点# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# s...原创 2019-09-22 20:14:17 · 80 阅读 · 0 评论 -
leetcode155. 最小栈
设计一个支持 push,pop,top 操作,并能在常数时间内检索到最小元素的栈。push(x) -- 将元素 x 推入栈中。pop() -- 删除栈顶的元素。top() -- 获取栈顶元素。getMin() -- 检索栈中的最小元素。class MinStack(object): def __init__(self): """ initia...原创 2019-09-22 17:45:09 · 75 阅读 · 0 评论 -
leetcode141. 环形链表
给定一个链表,判断链表中是否有环。为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置(索引从 0 开始)。 如果 pos 是 -1,则在该链表中没有环。解法1:直接法思路:遍历链表,将已经经过的位置存入target数组,如果遍历位置指向的下一个值位置在target数组中,说表构成环形链表# Definition for singly-linked list.#...原创 2019-09-22 16:55:31 · 69 阅读 · 0 评论 -
leetcode125. 验证回文串
给定一个字符串,验证它是否是回文串,只考虑字母和数字字符,可以忽略字母的大小写。说明:本题中,我们将空字符串定义为有效的回文串。解法1.正则提取思路:使用正则表达式提取其中的字母和数字,并转换为小写class Solution(object): def isPalindrome(self, s): """ :type s: str ...原创 2019-09-22 16:28:06 · 71 阅读 · 0 评论 -
Python3函数介绍(二)——函数创建
1.创建函数2.递归函数原创 2018-11-07 21:13:42 · 115 阅读 · 0 评论 -
Python3函数介绍(一)——函数参数
1.参数类型①位置参数②关键字参数③默认参数④可变参数(收集参数)⑤参数解包2.初始化数据结构未完待续……原创 2018-11-07 21:11:53 · 140 阅读 · 0 评论 -
leetcode189. 旋转数组
方法1.拼接数组法思路: 队尾各项 + 队首各项之和class Solution(object): def rotate(self, nums, k): """ :type nums: List[int] :type k: int :rtype: None Do not return anything, modify n...原创 2019-10-04 20:33:42 · 66 阅读 · 0 评论