2016刷题
文章平均质量分 64
hyperbolechi
这个作者很懒,什么都没留下…
展开
-
29. Divide Two Integers leetcode python new season 2016
Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.class Solution(object): MAX_INT = 0x7FFFFFFF def divide(self, divide原创 2016-01-12 12:14:40 · 387 阅读 · 0 评论 -
19. Remove Nth Node From End of List leetcode Python 2016 new Season
Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the l原创 2016-01-07 10:29:03 · 306 阅读 · 0 评论 -
42. Trapping Rain Water leetcode Python 2016 new season
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1],原创 2016-01-24 14:01:23 · 623 阅读 · 0 评论 -
40. Combination Sum II leetcode Python 2016 new season
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 may only be used once in the combina原创 2016-01-24 10:58:45 · 871 阅读 · 0 评论 -
18. 4Sum leetcode Python 2016 new Season
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.Note:Elements原创 2016-01-06 21:24:41 · 498 阅读 · 0 评论 -
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 telephone buttons) is given below.Input:Digit string原创 2016-01-06 21:02:16 · 355 阅读 · 0 评论 -
39. Combination Sum leetcode python 2016 new season
Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from C unlimited numb原创 2016-01-23 13:48:33 · 502 阅读 · 0 评论 -
16. 3Sum Closest leetcode Python 2016 new Season
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 that each input would have exact原创 2016-01-06 11:31:39 · 564 阅读 · 0 评论 -
15. 3Sum leetcode python 2016 new Season
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c)原创 2016-01-06 11:07:01 · 353 阅读 · 0 评论 -
195. Tenth Line leetcode bash
How would you print just the 10th line of a file?For example, assume that file.txt has the following content:Line 1Line 2Line 3Line 4Line 5Line 6Line 7Line 8Line 9Line 10Your script原创 2016-01-06 10:47:53 · 616 阅读 · 0 评论 -
20. Valid Parentheses leetcode Python 2016 new Season
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are all vali原创 2016-01-07 10:41:39 · 345 阅读 · 0 评论 -
43. Multiply Strings leetcode python 2016 new season
Total Accepted: 51879 Total Submissions: 231091 Difficulty: MediumGiven two numbers represented as strings, return multiplication of the numbers as a string.Note: The numbers can be arbi原创 2016-01-25 04:46:28 · 704 阅读 · 0 评论 -
28. Implement strStr() leetcode Python new season 2016
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Show Company TagsShow TagsShow Similar Problems原创 2016-01-12 11:43:21 · 379 阅读 · 0 评论 -
27. Remove Element leetcode python 2016 new season
Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't matter what you leave beyond the new length.t原创 2016-01-12 11:32:54 · 560 阅读 · 0 评论 -
25. Reverse Nodes in k-Group leetcode Python 2016 new season
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is原创 2016-01-12 11:14:08 · 466 阅读 · 0 评论 -
24. Swap Nodes in Pairs leetcode Python 2016 new Season
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 should use only constant space. You m原创 2016-01-10 12:07:50 · 418 阅读 · 0 评论 -
23. Merge k Sorted Lists python leetcode 2016 new Season
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.use priority queue will take O(n) time cause get max from priority will only take O(1)#原创 2016-01-10 11:44:20 · 596 阅读 · 0 评论 -
22. Generate Parentheses leetcode Python 2016 new Season
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:"((()))", "(()())", "(())()", "()(())", "()()原创 2016-01-08 13:02:33 · 359 阅读 · 0 评论 -
21. Merge Two Sorted Lists leetcode Python 2016 new Season
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.# Definition for singly-linked list.# class ListNo原创 2016-01-08 12:44:46 · 346 阅读 · 0 评论 -
45. Jump Game II leetcode python 2016 new season
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 that position.Your goal is to原创 2016-01-25 13:14:07 · 613 阅读 · 0 评论 -
44. Wildcard Matching leetcode Python 2016 new season
Implement wildcard pattern matching with support for '?' and '*'.'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover t原创 2016-01-25 07:09:19 · 840 阅读 · 0 评论 -
194. Transpose File leetcode Bash
Given a text file file.txt, transpose its content.You may assume that each row has the same number of columns and each field is separated by the ' ' character.For example, if file.txt has the原创 2016-01-06 10:46:16 · 915 阅读 · 0 评论 -
193. Valid Phone Numbers leetcode Bash
Given a text file file.txt that contains list of phone numbers (one per line), write a one liner bash script to print all valid phone numbers.You may assume that a valid phone number must appear原创 2016-01-06 10:42:45 · 807 阅读 · 0 评论 -
192. Word Frequency My Submissions Question Leetcode Bash
Write a bash script to calculate the frequency of each word in a text file words.txt.For simplicity sake, you may assume:words.txt contains only lowercase characters and space ' ' characters原创 2016-01-06 10:40:14 · 691 阅读 · 0 评论 -
6. ZigZag Conversion Leetcode Python 2016 new Season
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)P A H NA P L S I原创 2016-01-04 10:29:08 · 319 阅读 · 0 评论 -
5. Longest Palindromic Substring Leetcode Python 2016 new Season
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longest palindromic substring.Show Company Tags原创 2016-01-04 10:24:39 · 262 阅读 · 0 评论 -
33. Search in Rotated Sorted Array leetcode python 2016 new season
Suppose a sorted array 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 are given a target value to search. If found in the array retur原创 2016-01-19 12:46:59 · 383 阅读 · 0 评论 -
32. Longest Valid Parentheses leetcode python new season 2016
Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()",原创 2016-01-18 14:35:19 · 353 阅读 · 0 评论 -
31. Next Permutation leetcode Python 2016 new Season
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible原创 2016-01-18 14:20:38 · 448 阅读 · 0 评论 -
30. Substring with Concatenation of All Words leetcode Python 2016 new season
You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in wordsexactly once and w原创 2016-01-18 01:00:44 · 298 阅读 · 0 评论 -
2.Add Two Numbers Leetcode Python New season for 2016
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link原创 2015-12-29 10:52:03 · 428 阅读 · 0 评论 -
4. Median of Two Sorted Arrays leetcode python New season for 2016
There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).the main idea is if nums1原创 2015-12-30 11:26:25 · 355 阅读 · 0 评论 -
3. Longest Substring Without Repeating Characters Leetcode Python New season for 2016
Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3. Fo原创 2015-12-29 11:54:00 · 293 阅读 · 0 评论 -
9. Palindrome Number Leetcode Python 2016 new Season
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Show TagsShow Similar ProblemsT原创 2016-01-04 10:33:17 · 252 阅读 · 0 评论 -
34. Search for a Range leetcode Python 2016 new season
Given a sorted array of integers, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the target is not found原创 2016-01-20 10:51:54 · 477 阅读 · 0 评论 -
14. Longest Common Prefix leetcode Python 2016 new Season
Write a function to find the longest common prefix string amongst an array of strings.to compare all the strings assume the longest_prefix's length is m and there are n strings. we will need at leas原创 2016-01-05 20:56:03 · 311 阅读 · 0 评论 -
13. Roman to Integer leetcode Python 2016 new Season
Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.O(n) time go through the whole string. O(1) space.class Solution(object): def原创 2016-01-05 20:47:34 · 284 阅读 · 0 评论 -
12. Integer to Roman python leetcode 2016 new Season
Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.store the roman and values in arrays and iterate array to get the value. takes O原创 2016-01-05 11:26:01 · 279 阅读 · 0 评论 -
11. Container With Most Water leetcode Python 2016 new Season
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Fin原创 2016-01-05 11:15:33 · 295 阅读 · 0 评论 -
10. Regular Expression Matching leetcode Python 2016 new Season
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st原创 2016-01-04 20:52:00 · 368 阅读 · 0 评论