leetcode
文章平均质量分 71
ghoshorn
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
leetcode 19 Remove Nth Node From End of List
Remove Nth Node From End of List 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原创 2015-04-12 15:05:59 · 414 阅读 · 0 评论 -
leetcode 3 Longest Substring Without Repeating Characters
Longest Substring Without Repeating Characters Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters原创 2015-03-18 15:29:27 · 342 阅读 · 0 评论 -
leetcode 1 Two Sum
Two Sum Given an array of integers, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to th原创 2015-03-18 15:24:16 · 334 阅读 · 0 评论 -
leetcode 18 4Sum
4Sum 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:原创 2015-04-14 18:24:25 · 403 阅读 · 0 评论 -
leetcode 25 Reverse Nodes in k-Group
Reverse Nodes in k-Group 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 i原创 2015-04-14 16:32:37 · 366 阅读 · 0 评论 -
leetcode 24 Swap Nodes in Pairs
Swap Nodes in Pairs 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 sho原创 2015-04-14 15:32:24 · 382 阅读 · 0 评论 -
leetcode 14 Longest Common Prefix
Longest Common Prefix Write a function to find the longest common prefix string amongst an array of strings. 需要注意的特殊情况:输入是个空列表 import unittest class Solution: # @return a string def l原创 2015-04-08 11:17:20 · 400 阅读 · 0 评论 -
leetcode 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 yourself what are the possible input ca原创 2015-03-20 17:03:29 · 327 阅读 · 0 评论 -
leetcode 4 Median of Two Sorted Arrays
Median of Two Sorted Arrays There are two sorted arrays A and B 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)).原创 2015-03-19 14:57:32 · 411 阅读 · 0 评论 -
leetcode 13 Roman to Integer
Roman to Integer Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999. 从字符串中每次处理一位,处理前需要先找到剩余串的枢纽(剩余串中最大的),以判断当前值在其左边还是右边,该相加还是相减。 i原创 2015-04-08 10:57:06 · 383 阅读 · 0 评论 -
leetcode 9 Palindrome Number
Palindrome Number Determine whether an integer is a palindrome. Do this without extra space. click to show spoilers. Some hints: Could negative integers be palindromes? (ie, -1) If yo原创 2015-03-20 17:23:19 · 323 阅读 · 0 评论 -
leetcode 15 3Sum
3Sum 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 tr原创 2015-04-08 17:26:11 · 450 阅读 · 0 评论 -
leetcode 7 Reverse digits of an integer
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 class Solution: # @return an integer def reverse(self, x): tmp=abs(x) if tm原创 2015-03-20 16:38:57 · 377 阅读 · 0 评论 -
leetcode 11 Container With Most Water
Container With Most Water 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 lin原创 2015-04-07 17:42:27 · 318 阅读 · 0 评论 -
leetcode 5 Longest Palindromic Substring
Longest Palindromic Substring 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 palindrom原创 2015-03-19 18:03:14 · 315 阅读 · 0 评论 -
leetcode 10 Regular Expression Matching & 44 Wildcard Matching
leetcode中的两个 正则表达式匹配原创 2015-03-26 14:44:30 · 608 阅读 · 0 评论 -
leetcode 21 Merge Two Sorted Lists
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. # Definition for sin原创 2015-04-12 16:09:18 · 353 阅读 · 0 评论 -
leetcode 22 Generate Parentheses
Generate Parentheses 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: "((()))", "(()原创 2015-04-12 16:45:12 · 366 阅读 · 0 评论 -
leetcode 23 Merge k Sorted Lists
Merge k Sorted Lists Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. 可以通过leetcode 21的merge Two Lists来解决。 如果从头到尾依此合并,会超时。 改用分治法来调用。链表个数l>3时,原创 2015-04-12 17:09:48 · 440 阅读 · 0 评论 -
leetcode 16 3Sum Closest
3Sum Closest 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 inpu原创 2015-04-12 13:51:33 · 340 阅读 · 0 评论 -
leetcode 17 Letter Combinations of a Phone Number
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原创 2015-04-12 14:32:27 · 397 阅读 · 0 评论 -
leetcode 20 Valid Parentheses
Valid Parentheses Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()"原创 2015-04-12 15:53:18 · 356 阅读 · 0 评论 -
leetcode 26 Remove Duplicates from Sorted Array
Remove Duplicates from Sorted Array Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for原创 2015-04-13 15:14:01 · 475 阅读 · 0 评论 -
leetcode 30 Substring with Concatenation of All Words
Substring with Concatenation of All Words You are given a string, S, and a list of words, L, that are all of the same length. Find all starting indices of substring(s) in S that is a concatenat原创 2015-04-13 16:29:44 · 459 阅读 · 0 评论 -
leetcode 28 Implement strStr()
Implement strStr() Implement strStr(). Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 要注意特殊情况,比如strstr("","") 应该等于0 =_= class原创 2015-04-13 15:46:09 · 283 阅读 · 0 评论 -
leetcode 27 Remove Element
Remove Element 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 be原创 2015-04-13 15:23:05 · 375 阅读 · 0 评论 -
leetcode 29 Divide Two Integers
Divide Two Integers Divide two integers without using multiplication, division and mod operator. If it is overflow, return MAX_INT. class Solution1: # @return an integer def divi原创 2015-04-13 16:07:41 · 358 阅读 · 0 评论 -
leetcode 12 Integer to Roman
数字转换为罗马数字原创 2015-04-07 19:11:24 · 370 阅读 · 0 评论 -
leetcode 6 ZigZag Conversion
ZigZag Conversion 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)原创 2015-03-20 16:16:43 · 291 阅读 · 0 评论
分享