leetcode
文章平均质量分 73
雨中鹰
这个作者很懒,什么都没留下…
展开
-
[leetcode]Summary Ranges
Summary Ranges Given a sorted integer array without duplicates, return the summary of its ranges.For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].public class Solution {原创 2015-07-04 09:00:21 · 434 阅读 · 0 评论 -
[leetcode]Word Break II
Word Break II Total Accepted: 8514 Total Submissions: 54862My SubmissionsGiven a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a val原创 2014-05-16 21:36:25 · 566 阅读 · 0 评论 -
[leetcode]Permutation Sequence
Permutation Sequence The set [1,2,3,…,n] contains a total of n! unique permutations.By listing and labeling all of the permutations in order,We get the following sequence (ie, for n原创 2014-04-24 09:47:11 · 449 阅读 · 0 评论 -
[leetcode]Restore IP Addresses
Restore IP Addresses My SubmissionsGiven a string containing only digits, restore it by returning all possible valid IP address combinations.For example:Given "25525511135",return ["原创 2014-04-21 08:36:02 · 586 阅读 · 0 评论 -
[leetcode]Reorder List
Reorder List Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3原创 2014-05-14 20:47:07 · 436 阅读 · 0 评论 -
[leetcode]Insertion Sort List
Insertion Sort List Sort a linked list using insertion sort.原创 2014-05-14 19:40:30 · 365 阅读 · 0 评论 -
[leetcode]Rotate Array
Rotate Array Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as m原创 2015-04-12 22:16:26 · 324 阅读 · 0 评论 -
[leetcode]Compare Version Numbers
Compare Version Numbers Compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 version2 return -1, otherwise return 0.You may assume that the vers原创 2015-04-19 13:32:28 · 422 阅读 · 0 评论 -
[leetcode]Largest Number
Largest NumberGiven a list of non negative integers, arrange them such that they form the largest number.For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330.No原创 2015-04-12 22:22:19 · 352 阅读 · 0 评论 -
[leetcode]Binary Tree Maximum Path Sum
Binary Tree Maximum Path Sum Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1原创 2014-04-20 19:38:35 · 650 阅读 · 0 评论 -
[leetcode]surrounded regions
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For example,X X X XX O O XX X原创 2014-03-29 22:36:16 · 563 阅读 · 0 评论 -
[leetcode]Palindrome Partitioning
Palindrome Partitioning Total Accepted: 10359 Total Submissions: 40314My SubmissionsGiven a string s, partition s such that every substring of the partition is a palindrome.Return all原创 2014-05-16 21:23:43 · 490 阅读 · 0 评论 -
[leetcode]Word Break
Word Break 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 words.For example, givens = "leetcod原创 2014-05-16 21:27:57 · 402 阅读 · 0 评论 -
[leetcode]Minimum Window Substring
Minimum Window Substring Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example,S = "ADOBECODEBANC"T =原创 2014-05-21 10:19:46 · 443 阅读 · 0 评论 -
[leetcode]Rotate List
Rotate List Given a list, rotate the list to the right by k places, where k is non-negative.For example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.原创 2014-04-24 21:08:05 · 429 阅读 · 0 评论 -
[leetcode]Maximum Depth of Binary Tree
Maximum Depth of Binary Tree Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.原创 2014-05-24 21:58:01 · 452 阅读 · 0 评论 -
[leetcode]Course Schedule II
Course Schedule II There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take cours原创 2015-05-14 09:53:51 · 839 阅读 · 0 评论 -
[leetcode]Word Search
Word Search 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 those horizo原创 2014-04-19 13:49:12 · 496 阅读 · 0 评论 -
[leetcode]First Missing Positive
First Missing Positive Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run i原创 2014-05-07 17:22:41 · 387 阅读 · 0 评论 -
[leetcode]Set Matrix Zeroes
Set Matrix Zeroes Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place.click to show follow up.Follow up:Did you use extra space?A straight fo原创 2014-04-06 21:43:35 · 467 阅读 · 0 评论 -
[leetcode]Same Tree
Same Tree Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same va原创 2014-05-24 22:03:58 · 581 阅读 · 0 评论 -
[leetcode]Contains Duplicate II
Contains Duplicate II Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference原创 2015-06-12 16:03:13 · 364 阅读 · 0 评论 -
[leetcode]Contains Duplicate
Contains Duplicate Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should ret原创 2015-06-12 16:00:33 · 481 阅读 · 0 评论 -
[leetcode]Rectangle Area
Rectangle Area Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as shown in the figure.原创 2015-06-12 10:32:54 · 372 阅读 · 0 评论 -
[leetcode]Add and Search Word - Data structure design
Add and Search Word - Data structure design Design a data structure that supports the following two operations:void addWord(word)bool search(word)search(word) can search a literal word原创 2015-05-16 16:23:54 · 499 阅读 · 0 评论 -
[leetcode]Subsets II
Subsets II Given a collection of integers that might contain duplicates, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set原创 2015-05-14 21:41:25 · 297 阅读 · 0 评论 -
[leetcode]Subsets
Subsets Given a set of distinct integers, nums, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subs原创 2015-05-14 20:04:35 · 330 阅读 · 0 评论 -
[leetcode]Flatten Binary Tree to Linked List
Flatten Binary Tree to Linked List Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The f原创 2014-04-20 20:05:07 · 375 阅读 · 0 评论 -
[leetcode]Jump Game I II
Jump Game 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 positi原创 2014-04-18 21:36:23 · 485 阅读 · 0 评论 -
[leetcode]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 let原创 2014-04-17 21:35:44 · 375 阅读 · 0 评论 -
[leetcode]Binary Tree Zigzag Level Order Traversal
Binary Tree Zigzag Level Order Traversal Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level a原创 2014-04-17 16:52:10 · 429 阅读 · 0 评论 -
[leetcode]Single Number II
Single Number II My SubmissionsGiven an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime compl原创 2014-04-02 21:03:18 · 595 阅读 · 0 评论 -
[leetcode]Interleaving String
Interleaving String Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.For example,Given:s1 = "aabcc",s2 = "dbbca",When s3 = "aadbbcbcac", return true.原创 2014-05-22 09:06:12 · 518 阅读 · 0 评论 -
[leetcode]Next Permutation
Next Permutation Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange原创 2014-04-24 20:56:10 · 465 阅读 · 0 评论 -
[leetcode]Binary Tree Preorder Traversal
Binary Tree Preorder Traversal Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return原创 2014-05-14 19:57:34 · 329 阅读 · 0 评论 -
[leetcode]Evaluate Reverse Polish Notation
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 expre原创 2014-05-14 19:29:37 · 480 阅读 · 0 评论 -
[leetcode]Reverse Words in a String
Reverse Words in a String Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".Clarification:What constitut原创 2014-05-14 19:25:50 · 417 阅读 · 0 评论 -
[leetcode]Merge Intervals
Merge Intervals 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].原创 2014-05-22 10:07:54 · 479 阅读 · 0 评论 -
[leetcode]Longest Valid Parentheses
Longest Valid Parentheses My SubmissionsGiven a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", t原创 2014-04-06 21:29:14 · 534 阅读 · 0 评论 -
[leetcode]Palindrome Partitioning II
Palindrome Partitioning II Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.For原创 2014-05-23 20:24:33 · 472 阅读 · 0 评论