摘要: 1.题目 可以删除一个字符,判断是否能构成回文字符串。: Input: "abca" Output: True Explanation: You could delete the character 'c'. 2.代码实现: class Solution(object): def validPali 阅读全文
posted @ 2020-04-09 12:02 Mustardseed 阅读(82) 评论(0) 推荐(0)
摘要: 1.题目 找到字符串中的元音,翻转如下: Given s = "leetcode", return "leotcede". 2.代码实现: class Solution: def reverseVowels(self, s: str) -> str: dict = {'a','e','i','o', 阅读全文
posted @ 2020-04-09 10:51 Mustardseed 阅读(142) 评论(0) 推荐(0)
摘要: 1.题目描述: 判断一个非负整数是否为两个整数的平方和。 2.同Leetcode167,使用双指针来解题 import math class Solution: def judgeSquareSum(self, c: int) -> bool: if c < 0: return False #如果c 阅读全文
posted @ 2020-04-09 10:11 Mustardseed 阅读(135) 评论(0) 推荐(1)
摘要: 1.题目描述:在有序数组中找出两个数,使它们的和为 target。 Input: numbers={2, 7, 11, 15}, target=9 Output: index1=1, index2=2 2.解题思路:1.升序排列的数组2.使用双指针,一个指针指向值较小的元素,另一个指针指向值较大的索 阅读全文
posted @ 2020-04-09 09:29 Mustardseed 阅读(209) 评论(0) 推荐(0)