
LeetCode
文章平均质量分 77
JoJo93
这个作者很懒,什么都没留下…
展开
-
1 LeetCode Two Sum
题目: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use原创 2018-01-17 10:59:27 · 226 阅读 · 0 评论 -
LeetCode Add Two Numbers
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ class Solution { public: ListNode* ad...原创 2018-03-14 01:47:02 · 212 阅读 · 0 评论 -
Leetcode 7 整数反转 python3
训练一下python3的语法,刷一些水题 在本题中,学习到了python3中 1.整型范围没有限制 2.字符串翻转[::-1] 3.字符串与整型互转 str() int() class Solution: def reverse(self, x: int) -> int: negative = False if x < 0: ...原创 2019-05-16 16:41:48 · 210 阅读 · 0 评论 -
Leetcode 5 最长回文子串 Manacher O(n)
python练习题,本题学习的知识点: 1.range(n,m)范围是n~m-1 2.申请一个数组 L = [0] * N 申请一个N长度的Int数组,并初始值赋值为0 以下为本题解法: O(n)时间复杂度方法——Manacher算法 转载自:https://blog.youkuaiyun.com/qq_32354501/article/details/80084325 1.思想: ...原创 2019-05-17 16:59:06 · 305 阅读 · 0 评论 -
Leetcode 122 买卖股票的最佳时机 II
简单递推, 求一个数列中所有上升队列的差值的和. python知识点: 1.求list的长度,len(list) class Solution: def maxProfit(self, prices: List[int]) -> int: result = 0 for idx in range(len(prices)): ...原创 2019-05-17 17:31:00 · 181 阅读 · 0 评论 -
Leetcode 136 只出现过一次的数字
异或运算 class Solution: def singleNumber(self, nums: List[int]) -> int: result = 0 for num in nums: result = result ^ num return result原创 2019-05-17 17:34:25 · 174 阅读 · 0 评论