leetcode
灵魂画手-编程如画
大工小本,计算所小硕一枚,奋斗ing,相信技术改变世界!
展开
-
91. Decode Ways(Python3)
91. Decode Ways(Python3)题目A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digit原创 2018-01-30 10:44:02 · 396 阅读 · 0 评论 -
31. Next Permutation(Python3)
31. Next Permutation(Python3)题目Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must re原创 2018-01-25 23:47:05 · 944 阅读 · 0 评论 -
25. Reverse Nodes in k-Group(Python3)
25. Reverse Nodes in k-Group(Python3)题目Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the l原创 2018-01-25 23:07:16 · 407 阅读 · 0 评论 -
24. Swap Nodes in Pairs(Python3)
24. Swap Nodes in Pairs(Python3)题目Given a linked list, swap every two adjacent nodes and return its head.For example, Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm原创 2018-01-25 14:06:50 · 218 阅读 · 0 评论 -
22. Generate Parentheses(Python3)
22. Generate Parentheses(Python3)题目Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "(((原创 2018-01-25 10:57:15 · 510 阅读 · 0 评论 -
14. Longest Common Prefix
14. Longest Common Prefix题目Write a function to find the longest common prefix string amongst an array of strings.解题方案标签:String解析:这道题的代码是用的leetcode提交最快的,很短小惊艳zip、set和min都有其妙用代码:class原创 2018-01-08 19:51:43 · 182 阅读 · 0 评论 -
16. 3Sum Closest(Python3)
16. 3Sum Closest(Python3)题目Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume tha原创 2018-01-25 10:34:03 · 339 阅读 · 0 评论 -
12. Integer to Roman(Python3)
12. Integer to Roman题目Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.解题方案代码:class Solution: def intToRoman(self, num):原创 2018-01-25 00:51:18 · 256 阅读 · 0 评论 -
8. String to Integer (atoi)
8. String to Integer (atoi)题目Implement atoi to convert a string to an integer.**Hint:**Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yours原创 2018-01-25 00:21:26 · 162 阅读 · 0 评论 -
12. Integer to Roman
12. Integer to Roman题目描述:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.题目翻译将整数转化成罗马数字,其中输入数据范围是1到3999解题方案标签: 数学, 字符串思路原创 2018-01-17 00:02:18 · 203 阅读 · 0 评论 -
219. Contains Duplicate II
219. Contains Duplicate II题目Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the absolute differenc原创 2018-01-05 10:06:34 · 173 阅读 · 0 评论 -
9. Palindrome Number
9. Palindrome Number题目Determine whether an integer is a palindrome. Do this without extra space.解题方案标签:String代码:class Solution: def isPalindrome(self, x): """ :type x: int :原创 2017-12-29 13:25:02 · 187 阅读 · 0 评论 -
21. Merge Two Sorted Lists
21. Merge Two Sorted Lists题目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原创 2018-01-09 14:24:41 · 230 阅读 · 0 评论 -
2. Add Two Numbers
2. Add Two Numbers题目You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two n原创 2017-12-28 13:56:59 · 200 阅读 · 0 评论 -
66. Plus One
66. Plus One题目Given a non-negative integer represented as a non-empty array of digits, plus one to the integer.You may assume the integer do not contain any leading zero, except the number 0 itself.The原创 2017-12-28 11:54:49 · 249 阅读 · 0 评论 -
396. Rotate Function
396. Rotate Function题目Given an array of integers A and let n to be its length.Assume Bk to be an array obtained by rotating the array A k positions clock-wise, we define a “rotation function”F on Aas f原创 2017-12-27 19:11:40 · 299 阅读 · 0 评论 -
33. Search in Rotated Sorted Array(Python3)
33. Search in Rotated Sorted Array(Python3)题目Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You原创 2018-01-26 10:40:03 · 431 阅读 · 0 评论 -
34. Search for a Range(Python3)
34. Search for a Range(Python3)题目Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm’s runtime complexity must be i原创 2018-01-26 11:15:17 · 297 阅读 · 0 评论 -
89. Gray Code(Python3)
89. Gray Code(Python3)题目The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the co原创 2018-01-30 00:02:22 · 542 阅读 · 0 评论 -
82. Remove Duplicates from Sorted List II(Python3)
82. Remove Duplicates from Sorted List II(Python3)题目Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.For example, G原创 2018-01-29 17:43:53 · 377 阅读 · 0 评论 -
79. Word Search(Python3)
79. Word Search(Python3)题目Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where “adjacent” cells are thos原创 2018-01-29 15:24:03 · 711 阅读 · 0 评论 -
78. Subsets(Python3)
78. Subsets(Python3)题目Given a set of distinct integers, nums, return all possible subsets (the power set).Note: The solution set must not contain duplicate subsets.For example, If nums = [1,2原创 2018-01-29 13:44:57 · 738 阅读 · 0 评论 -
17. Letter Combinations of a Phone Number(Python3)
17. Letter Combinations of a Phone Number题目Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telepho原创 2018-01-12 11:05:21 · 497 阅读 · 0 评论 -
75. Sort Colors(Python3)
75. Sort Colors(Python3)题目Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.Her原创 2018-01-29 13:07:15 · 359 阅读 · 0 评论 -
74. Search a 2D Matrix(Python3)
74. Search a 2D Matrix(Python3)题目Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted from left to原创 2018-01-29 12:12:17 · 325 阅读 · 0 评论 -
73. Set Matrix Zeroes(Python3)
73. Set Matrix Zeroes(Python3)题目Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.Follow up: Did you use extra space? A straight forward solution usi原创 2018-01-29 10:55:52 · 328 阅读 · 0 评论 -
71. Simplify Path(Python3)
71. Simplify Path(Python3)题目Given an absolute path for a file (Unix-style), simplify it.For example, path = “/home/”, => “/home” path = “/a/./b/../../c/”, => “/c” click to show corner cases.原创 2018-01-28 09:41:38 · 446 阅读 · 0 评论 -
56. Merge Intervals(Python3)
56. Merge Intervals(Python3)题目Given a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18].解题方案思路:首先根据star原创 2018-01-27 14:40:49 · 577 阅读 · 0 评论 -
55. Jump Game(Python3)
55. Jump Game(Python3)题目Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at tha原创 2018-01-27 11:48:21 · 560 阅读 · 0 评论 -
49. Group Anagrams(Python3)
49. Group Anagrams(Python3)题目Given an array of strings, group anagrams together.For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return:[ ["ate", "eat","tea"], ["nat","tan原创 2018-01-26 21:23:53 · 275 阅读 · 0 评论 -
47. Permutations II(Python3)
47. Permutations II(Python3)题目Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations:原创 2018-01-26 19:29:25 · 401 阅读 · 0 评论 -
46. Permutations(Python3)
46. Permutations(Python3)题目Given a collection of distinct numbers, return all possible permutations.For example, [1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [原创 2018-01-26 19:10:28 · 1416 阅读 · 0 评论 -
40. Combination Sum II(Python3)
40. Combination Sum II(Python3)题目Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.Each number in C m原创 2018-01-26 18:45:41 · 371 阅读 · 0 评论 -
70. Climbing Stairs
70. Climbing Stairs题目You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: G原创 2018-01-10 10:11:38 · 353 阅读 · 0 评论 -
39. Combination Sum(Python3)
39. Combination Sum(Python3)题目Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The sam原创 2018-01-26 16:33:28 · 732 阅读 · 0 评论 -
205. Isomorphic Strings
205. Isomorphic Strings题目Given two strings s and t, determine if they are isomorphic.Two strings are isomorphic if the characters in s can be replaced to get t.All occurrences of a character must be re原创 2017-12-27 17:34:22 · 183 阅读 · 0 评论 -
518. Coin Change 2
518. Coin Change 2题目You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you原创 2017-12-27 16:17:42 · 275 阅读 · 0 评论 -
136. Single Number
136. Single Number题目Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implem原创 2018-01-11 23:28:50 · 199 阅读 · 0 评论 -
609. Find Duplicate File in System
609. Find Duplicate File in System1 题目You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way.The null node needs to be represented by em原创 2017-06-13 16:15:37 · 336 阅读 · 0 评论 -
575. Distribute Candies
575. Distribute Candies1 题目Given an integer array with even length, where different numbers in this array represent different kinds of candies. Each number means one candy of the corresponding kind. Yo原创 2017-06-20 13:25:09 · 408 阅读 · 0 评论