LeetCode刷题Python
swedishsunset
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode#12. Integer to Roman-Medium
罗马数字表示的数字,每一位都可以分开进行处理,所以将个位,十位,百位,千位可能的表示方法用list单独列出(因为这个题目有提示范围是在1-3999)class Solution(object): def intToRoman(self, num): """ :type num: int :rtype: str """ ...原创 2019-07-02 13:24:44 · 173 阅读 · 0 评论 -
Leetcode#21 Merge Two Sorted Lists-Easy
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1-...原创 2019-08-05 21:18:22 · 141 阅读 · 0 评论 -
Leetcode#17. Letter Combinations of a Phone Number-Medium
Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is giv...原创 2019-07-19 21:32:39 · 205 阅读 · 0 评论 -
Leetcode#16. 3Sum Closest_-Medium
Given an arraynumsofnintegers and an integertarget, find three integers innumssuch that the sum is closest totarget. Return the sum of the three integers. You may assume that each input would ...原创 2019-07-18 13:20:57 · 129 阅读 · 0 评论 -
Leetcode #15. 3Sum -Medium
Given an arraynumsofnintegers, are there elementsa,b,cinnumssuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.Note:The solution set must not conta...原创 2019-07-17 18:55:34 · 110 阅读 · 0 评论 -
LeetCode#18 4Sum-Medium
Given an arraynumsofnintegers and an integertarget, are there elementsa,b,c, anddinnumssuch thata+b+c+d=target? Find all unique quadruplets in the array which gives the sum oftar...原创 2019-07-26 15:45:37 · 144 阅读 · 0 评论 -
LeetCode#19-Medium
Given a linked list, remove then-th node from the end of list and return its head.Example:Given linked list: 1->2->3->4->5, and n = 2.After removing the second node from the end, t...原创 2019-07-30 18:01:56 · 137 阅读 · 0 评论 -
LeetCode #14. Longest Common Prefix-Easy
要求:Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".解题思路:要一位一位的比较,python中有一个zip(),可以实现一位一位比较zip()介...原创 2019-07-08 22:54:14 · 137 阅读 · 0 评论 -
LeetCode #13. Roman to Integer-Easy
罗马数字转为普通数字表示,其中需要注意的是特殊数字的表示方法,比如和4,9相关的表示方法,因为都是非单个字符表示,如果遍历转换会出现麻烦speciallist——特殊的罗马数字列表valuedic——罗马数字与普通数字对应关系的字典步骤:1.排查是是否有speciallist中的内容,有就记录下位置,通过valuedic得出对应的数字 2.将speciallis...原创 2019-07-02 13:42:30 · 193 阅读 · 0 评论 -
Leetcode#20 Valid Parentheses -Easy
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of b...原创 2019-08-01 22:15:40 · 153 阅读 · 0 评论
分享