![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
brook_
这个作者很懒,什么都没留下…
展开
-
LeetCode-两数之和
LeetCode-两数之和原创 2018-05-04 08:47:35 · 288 阅读 · 0 评论 -
LeetCode-回文数
判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数class Solution: def isPalindrome(self, x): """ :type x: int :rtype: bool """ string1 = str(x) list1 =...原创 2018-05-04 08:58:30 · 405 阅读 · 0 评论 -
LeetCode-翻转整数
给定一个 32 位有符号整数,将整数中的数字进行反转。class Solution: def reverse(self, x): """ :type x: int :rtype: int """ flag = 1 if x < 0 : flag = -1 ...原创 2018-05-04 10:03:23 · 235 阅读 · 0 评论 -
Leet-Code 无重复字符的最长子串
给定一个字符串,找出不含有重复字符的最长子串的长度。示例:给定 “abcabcbb” ,没有重复字符的最长子串是 “abc” ,那么长度就是3。给定 “bbbbb” ,最长的子串就是 “b” ,长度是1。给定 “pwwkew” ,最长子串是 “wke” ,长度是3。请注意答案必须是一个子串,”pwke” 是 子序列 而不是子串。class Solution: de...原创 2018-05-04 12:52:25 · 310 阅读 · 0 评论 -
LeetCode- 搜索插入位置
给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。你可以假设数组中无重复元素。示例 1:输入: [1,3,5,6], 5 输出: 2 示例 2:输入: [1,3,5,6], 2 输出: 1class Solution: def searchInsert(self, nums, target)...原创 2018-05-04 19:15:06 · 375 阅读 · 0 评论 -
LeetCode-存在重复元素
给定一个整数数组,判断是否存在重复元素。如果任何值在数组中出现至少两次,函数返回 true。如果数组中每个元素都不相同,则返回 false。class Solution: def containsDuplicate(self, nums): """ :type nums: List[int] :rtype: bool ...原创 2018-05-05 16:09:54 · 3560 阅读 · 4 评论 -
LeetCode- 同构字符串
给定两个字符串 s 和 t,判断它们是否是同构的。如果 s 中的字符可以被替换得到 t ,那么这两个字符串是同构的。所有出现的字符都必须用另一个字符替换,同时保留字符的顺序。两个字符不能映射到同一个字符上,但字符可以映射自己本身。示例 1:输入: s = “egg”, t = “add” 输出: true 示例 2:输入: s = “foo”, t = “bar” 输出:...原创 2018-05-05 17:02:55 · 360 阅读 · 0 评论