LeetCode
文章平均质量分 64
seawade
苦练基本功。
展开
-
LeetCode OJ --问题与解答 Sudoku Solver
题目Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that原创 2014-02-24 10:58:48 · 772 阅读 · 1 评论 -
LeetCode OJ --问题与解答 Evaluate Reverse Polish Notation
题目Evaluate the value of an arithmetic expression in Reverse Polish Notation.Valid operators are +, -, *, /. Each operand may be an integer or another expr原创 2014-02-16 20:00:16 · 484 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Max Points on a Line
题目Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.给出n个点,判断在这些点中在同一直线最多的点,有几个?思路原创 2014-02-17 22:24:53 · 603 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Reorder List
题目Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.给出n个点,判断在这些点中在同一直线最多的点,有几个?思路原创 2014-02-18 15:39:40 · 557 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Binary Tree Preorder Traversal
题目Given a binary tree, return the preorder traversal of its nodes' values.二叉树前序遍历。原创 2014-03-05 14:55:14 · 419 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Binary Tree Inorder Traversal
题目Given a binary tree, return the inorder traversal of its nodes' values.二叉树中序遍历。原创 2014-03-05 16:40:34 · 414 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Roman to Integer
题目Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.原创 2014-03-06 12:36:42 · 549 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Binary Tree Preorder Traversal
题目Given a binary tree, return the preorder traversal of its nodes' values.前序遍历,递归,迭代两种方式思路原创 2014-03-28 10:50:43 · 481 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Binary Tree Postorder Traversal
题目Given a binary tree, return the postorder traversal of its nodes' values.后序遍历,递归、迭代两种方式思路原创 2014-03-28 12:18:43 · 549 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Reverse Words in a String
题目Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return原创 2014-03-07 16:19:51 · 1166 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Regular Expression Matching
题目Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Mat原创 2014-07-30 16:29:04 · 773 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Largest Rectangle in Histogram
题目思路1 典型的DP算法 A[1,n],B[1,n]原创 2014-08-04 09:15:52 · 547 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Sort List
题目Sort a linked list in O(n log n) time using constant space complexity.思路原创 2014-08-01 15:11:50 · 437 阅读 · 0 评论 -
LeetCode OJ --问题与解答 Word BreakII
题目Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary原创 2014-08-02 21:46:35 · 394 阅读 · 0 评论 -
LeetCode 036 Valid Sudoku
题目Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled wi原创 2014-02-11 13:44:25 · 605 阅读 · 0 评论 -
LeetCode 023 Merge k Sorted Lists
题目把k个排序号的链表连接成一个有序链表。代码public class Solution { public ListNode mergeKLists(List lists) { i原创 2015-03-19 14:21:39 · 346 阅读 · 0 评论 -
LeetCode 002 Add Two Numbers
题目两个数,每位都按照链表倒序存储。求和,存入新的链表中。代码public class Solution { public ListNode addTwoNumbers(ListNode l1, ListNode l2) { ListNode原创 2015-03-15 10:17:13 · 337 阅读 · 0 评论 -
LeetCode 003 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原创 2014-02-20 10:49:41 · 610 阅读 · 0 评论 -
LeetCode 025 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原创 2014-02-19 23:41:53 · 507 阅读 · 0 评论 -
LeetCode 008 String to Integer (atoi)
题目完成atoi 的函数。特别要考虑corner。代码public class Solution { public int atoi(String str) { if(st原创 2015-03-19 15:00:50 · 415 阅读 · 0 评论 -
LeetCode 005 Longest Palindromic Substring
题目字符串中最长回文子串代码public class Solution { public String longestPalindrome(String s) { if(s ==原创 2015-03-19 23:23:56 · 301 阅读 · 0 评论 -
LeetCode 026 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 le原创 2014-03-07 12:20:23 · 488 阅读 · 0 评论 -
LeetCode 042 Trapping Rain Water
题目Given n non-negative integers representing an elevation map where the width of each bar is 1, comput原创 2014-08-15 10:26:08 · 490 阅读 · 0 评论 -
LeetCode 007 Reverse Integer
题目Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321把int 给倒序成为新的int思路原创 2014-02-28 21:31:46 · 704 阅读 · 0 评论 -
LeetCode 043 Multiply Strings
题目字符串相乘,乘数位正,可以任意大。代码原创 2015-03-26 16:23:28 · 382 阅读 · 0 评论 -
LeetCode 041 First Missing Positive
题目Given an unsorted integer array, find the first missing positive integer.Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses consta原创 2014-02-02 09:39:36 · 784 阅读 · 0 评论 -
LeetCode 000 前言
LeetCode Online Judge 是一个程序猿准备技术笔试的平台,很多同行都去上面high过。还没玩的,可见http://oj.leetcode.com/ 。 里面有150道题目和相应的讨论。我把里面的题目都努力做了一遍,并且记录下来,包含自己对问题的一些思路和看法,许多问题给出多种解答想法。都用java完成。我会努力以1天1篇的速度来完成,记录下来的主要目的是加深自己对原创 2014-02-02 08:47:39 · 3106 阅读 · 0 评论 -
LeetCode 045 Jump Game II
题目Given an array of non-negative integers, you are initially positioned at the first index原创 2015-03-26 22:24:40 · 370 阅读 · 0 评论 -
LeetCode 049 Anagrams
题目原文Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.译文输入一组字符串,输出所有重组字相同的字符串。解答首先,要理解 anag原创 2014-02-02 08:52:47 · 1081 阅读 · 0 评论 -
LeetCode 048 Rotate Image
题目You are given an n x n 2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do thi原创 2014-03-26 16:47:15 · 413 阅读 · 0 评论 -
LeetCode 047 Permutations II
题目Given a collection of numbers that might contain duplicates, return all possible unique pe原创 2014-03-23 21:40:51 · 595 阅读 · 0 评论 -
LeetCode 006 ZigZag Conversion
题目字符串按照zigzag排列,最后按照行输出结果。代码public class Solution { public String convert(String s, int nRow原创 2015-03-16 15:33:26 · 312 阅读 · 0 评论 -
LeetCode 009 Palindrome Number
题目Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the len原创 2014-08-13 11:13:22 · 431 阅读 · 0 评论 -
LeetCode 044 Wildcard Matching
题目字符串匹配 “." 匹配任意字符串 “?”匹配单个字符串代码原创 2015-03-26 22:32:34 · 368 阅读 · 0 评论 -
LeetCode 001 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原创 2014-02-08 23:54:34 · 785 阅读 · 0 评论 -
LeetCode 046 Permutations
题目Given a collection of numbers, return all possible permutations.For example,[1,2,3] have原创 2014-03-21 15:25:47 · 376 阅读 · 0 评论 -
LeetCode 050 pow(x,n)
题目Implement pow(x, n).完成函数x^n不成熟的思路1 return Math.pow(x,n)肯定可以。2 主体,考虑用迭代处理,递归需要的时间相同O(n),但是所用堆栈空间更大。3原创 2014-02-07 16:18:47 · 584 阅读 · 0 评论 -
LeetCode 027 Remove Element
题目Given an array and a value, remove all instances of that value in place and return the new length.The order of e原创 2014-03-07 09:13:03 · 720 阅读 · 0 评论 -
LeetCode 014 Longest Common Prefix
题目思路11 一开始考虑,从头原创 2014-08-17 12:07:19 · 505 阅读 · 0 评论 -
LeetCode 011 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 t原创 2014-03-26 14:28:46 · 685 阅读 · 0 评论