- 博客(38)
- 资源 (40)
- 问答 (2)
- 收藏
- 关注
原创 LeetCode 38 Count and Say(C,C++,Java,Python)
Problem:The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1 is read off as "one 1" or 11.11 is read off as "two 1s" or 21.21 i
2015-05-19 21:36:24 3519
原创 LeetCode 37 Sudoku Solver (C,C++,Java,Python)
Problem:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will be only one unique solution.
2015-05-19 13:11:05 2924
原创 LeetCode 36 Valid Sudoku (C,C++,Java,Python)
Problem:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A p
2015-05-18 22:56:46 3897
原创 LeetCode 35 Search Insert Position (C,C++,Java,Python)
Problem:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates
2015-05-18 20:33:01 1727
原创 LeetCode 34 Search for a Range (C,C++,Java,Python)
Problem: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
2015-05-14 21:28:11 1892
原创 LeetCode 33 Search in Rotated Sorted Array (C,C++,Java,Python)
Problem: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 t
2015-05-14 19:59:49 712
原创 LeetCode 32 Longest Valid Parentheses (C,C++,Java,Python)
Problem:Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substri
2015-05-14 17:16:32 1249
原创 LeetCode 31 Next Permutation (C,C++,Java,Python)
Problem: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 l
2015-05-14 14:36:42 2109
原创 LeetCode 30 Substring with Concatenation of All Words (C,C++,Java,Python)
Problem: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 wordsexac
2015-05-14 13:13:52 2126
原创 LeetCode 29 Divide Two Integers (C,C++,Java,Python)
Problem:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.Solution:不能乘除就加减就行了,但是一个问题是加减有可能速度太慢,因此需要转换,由于任何一个数都能表示成二进制,所以有d
2015-05-13 09:27:20 2985 1
原创 LeetCode 28 Implement strStr() (C,C++,Java,Python)
Problem:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The signature of the function ha
2015-05-12 11:59:17 2457
原创 LeetCode 27 Remove Element (C,C++,Java,Python)
Problem: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 ne
2015-05-11 20:40:46 1971
原创 LeetCode 26 Remove Duplicates from Sorted Array (C,C++,Java,Python)
Problem: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 another array, you must do this
2015-05-11 20:25:19 1127
原创 LeetCode 25 Reverse Nodes in k-Group (C,C++,Java,Python)
Problem: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 r
2015-05-11 19:55:08 1529
原创 LeetCode 24 Swap Nodes in Pairs (C,C++,Java,Python)
Problem: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 con
2015-05-11 16:37:22 2234 1
原创 LeetCode 23 Merge k Sorted Lists (C,C++,Java,Python)
Problem:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.Solution:采用胜者树的方法,胜者树介绍:胜者树,假如链表数组长度为n,链表元素总个数为k,那么时间复杂度为O(k*log(n))题目大意:
2015-05-11 15:39:00 1473
原创 LeetCode 22 Generate Parentheses (C,C++,Java,Python)
Problem: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-05-10 21:11:15 2260
原创 LeetCode 21 Merge Two Sorted Lists (C,C++,Java,Python)
Problem: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.Solution:两个有序链表,每次取头部最小的那个元素,然后将这个元素从原来链表
2015-05-10 17:15:00 1773 1
原创 LeetCode 20 Valid Parentheses (C,C++,Java,Python)
Problem:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}
2015-05-10 16:41:00 4219
原创 LeetCode 19 Remove Nth Node From End of List (C,C++,Java,Python)
Problem: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 fro
2015-05-10 16:07:27 1261
原创 LeetCode 18 4Sum (C,C++,Java,Python)
Problem: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-05-10 15:04:02 2500
原创 LeetCode 17 Letter Combinations of a Phone Number(C,C++,Java,Python)
Problem: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.
2015-05-10 13:39:32 3832
原创 LeetCode 16 3Sum Closest(C,C++,Java,Python)
Problem: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 woul
2015-05-09 22:26:02 2607
原创 LeetCode 15 3Sum (C,C++,Java,Python)
Problem: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
2015-05-09 21:06:57 5708
原创 LeetCode 14 Longest Common Prefix (C,C++,Java,Python)
Problem:Write a function to find the longest common prefix string amongst an array of strings.Solution:时间复杂度O(n)题目大意:给一个字符串数组,要找到这些字符串的最大前缀公共子串。解题思路:既然是公共子串,那每个字符串肯定都包含有,并且在头部,首先把第
2015-05-08 18:40:35 5898 2
原创 LeetCode 13 Roman to Integer (C,C++,Java,Python)
Problem:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.Solution:时间复杂度O(n)题目大意:与12题相反,给一个罗马数字,要求转化为十进制数字解题思路:Java源
2015-05-08 16:57:01 1323
原创 LeetCode 12 Integer to Roman(C,C++,Java,Python)
Problem:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.Solution:根据数字将每一位转换为罗马字符串即可,时间复杂度O(len(num))题目大意:给一个整数,将整数调整为罗马数字,
2015-05-08 13:13:53 1822
原创 LeetCode 11 Container With Most Water (C,C++,Java,Python)
Problem: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
2015-05-07 22:56:04 1808
原创 LeetCode 10 Regular Expression Matching (C,C++,Java,Python)
Problem: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 e
2015-05-07 21:02:00 1612
原创 LeetCode 9 Palindrome Number
Problem: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 you are thinkin
2015-05-07 11:21:40 622
原创 LeetCode 8 String to Integer (atoi) (C,C++,Java,Python)
Problem: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 pos
2015-05-07 10:38:53 3086
原创 LeetCode 7 Reverse Integer(C,C++,Java,Python)
Problem:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Have you thought about this?Here are some good questions to ask before coding. Bonus
2015-05-07 09:23:20 1330
原创 LeetCode 6 ZigZag Conversion (C,C++,Java,Python)
Problem: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
2015-05-06 22:55:25 1561
原创 LeetCode 5 Longest Palindromic Substring(C,C++,Python,Java)
Problem: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.Soluti
2015-05-06 15:38:22 2068
原创 LeetCode 4 Median of Two Sorted Arrays
Problem: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)).Solution:使用
2015-05-06 11:10:30 1369
原创 LeetCode 3 Longest Substring Without Repeating Characters
Problem: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 lengt
2015-05-05 20:20:38 598
原创 LeetCode 2 Add Two Numbers
Problem: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 retur
2015-05-05 18:25:05 882 1
原创 LeetCode 1 Two Sum 题解
Problem: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 the
2015-05-05 16:53:05 1839
安装Wine时需要的Flex最新版
2013-05-10
Linux与Windows相互远程工具
2013-05-10
Pattern Recongition Quiz
2014-11-22
精通Windows Sockets网络开发:基于Visual C++实现-带源码
2013-05-21
leetcode C语言 int**是怎么用的?
2015-09-11
Ext中json解析如何获取属性名
2015-08-05
TA创建的收藏夹 TA关注的收藏夹
TA关注的人