
LeetCode
文章平均质量分 85
iteye_12150
这个作者很懒,什么都没留下…
展开
-
leetcode: Lowest Common Ancestor of a Binary Search Tree
问题描述 Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined...原创 2016-02-16 21:28:32 · 98 阅读 · 0 评论 -
leetcode: Lowest Common Ancestor of a Binary Tree
问题描述Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined between two ...原创 2016-02-18 23:53:08 · 121 阅读 · 0 评论 -
leetcode: Number of Digit One
问题描述:Given an integer n, count the total number of digit 1 appearing in all non-negative integers less than or equal to n.For example:Given n = 13,Return 6, because digit 1 occurred in the follo...原创 2016-02-21 18:32:52 · 129 阅读 · 0 评论 -
leetcode: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 for "abcabcbb" is "abc", which the length i...原创 2016-02-24 22:48:10 · 82 阅读 · 0 评论 -
leetcode: Longest Common Prefix
问题描述:Write a function to find the longest common prefix string amongst an array of strings. 原问题链接:https://leetcode.com/problems/longest-common-prefix/ 问题分析: 这个问题相对来说比较好解决。对于一组string来说...原创 2016-02-25 07:31:43 · 149 阅读 · 0 评论 -
leetcode: Add Two Numbers
问题描述: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 ...2016-03-06 12:05:11 · 89 阅读 · 0 评论 -
leetcode: Median of Two Sorted Arrays
问题描述: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)). 原问题链接:https://l...原创 2016-03-09 23:29:33 · 107 阅读 · 0 评论 -
leetcode: 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 palindromic substring.原问题链接:https://le...原创 2016-03-10 22:08:07 · 92 阅读 · 0 评论 -
leetcode: 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)P A H NA ...原创 2016-03-11 22:12:24 · 79 阅读 · 0 评论 -
leetcode: Reverse Integer
问题描述:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321 原问题链接:https://leetcode.com/problems/reverse-integer/ 问题分析 将一个数字倒过来转换,看起来是一个很容易的过程。我们可以...2016-03-12 21:47:08 · 115 阅读 · 0 评论 -
leetcode: 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 ...原创 2016-03-13 09:17:06 · 77 阅读 · 0 评论 -
leetcode: Palindrome Number
问题描述:Determine whether an integer is a palindrome. Do this without extra space. 原问题链接:https://leetcode.com/problems/palindrome-number/ 问题分析 判断回文数字的问题其实思路也比较简单。就是每次从数字的最高位和最低位进行比较。如...原创 2016-03-13 15:53:02 · 84 阅读 · 0 评论 -
leetcode: Regular Expression Matching
问题描述: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 ent...原创 2016-03-17 23:37:36 · 170 阅读 · 0 评论 -
leetcode: 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 line i is at (i, ai) and (i, 0). ...原创 2016-03-19 17:18:38 · 89 阅读 · 0 评论 -
leetcode: Integer to Roman
问题描述:Given an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.原问题链接:https://leetcode.com/problems/integer-to-roman/ 问题分析 在分析问题前,我们先看一...原创 2016-03-20 22:39:20 · 147 阅读 · 0 评论 -
leetcode: Roman to Integer
问题描述:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.原问题链接:https://leetcode.com/problems/roman-to-integer/ 问题分析 在前面的文章中已经提到过罗...原创 2016-03-20 23:42:00 · 102 阅读 · 0 评论 -
leetcode: 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 triplet (a,b...原创 2016-03-21 21:49:11 · 76 阅读 · 0 评论 -
leetcode: 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 input would hav...原创 2016-03-21 23:13:26 · 83 阅读 · 0 评论 -
leetcode: 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:Di...原创 2016-03-22 20:48:22 · 105 阅读 · 0 评论 -
leetcode: 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:Eleme...原创 2016-03-23 21:32:44 · 87 阅读 · 0 评论 -
leetcode: 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 removing the second n...原创 2016-03-23 21:58:56 · 107 阅读 · 0 评论 -
leetcode: 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, "()" and "()[]{}" are all...原创 2016-03-23 23:24:24 · 100 阅读 · 0 评论 -
leetcode: 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.原问题链接:https://leetcode.com/problems/merge-two-so...2016-03-23 23:41:45 · 85 阅读 · 0 评论 -
leetcode: 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:"((()))", "(()())", "(())()", "()(())", "...原创 2016-03-24 21:35:37 · 87 阅读 · 0 评论 -
leetcode: Merge k Sorted Lists
问题描述:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.原问题链接:https://leetcode.com/problems/merge-k-sorted-lists/ 问题分析 这个问题看起来比较复杂,但是结合我前面...原创 2016-03-24 22:15:44 · 107 阅读 · 0 评论 -
leetcode: 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 should use o...原创 2016-03-25 21:43:53 · 79 阅读 · 0 评论 -
leetcode: 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 in the end should remain a...原创 2016-03-26 14:56:23 · 87 阅读 · 0 评论 -
leetcode: 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 another array, you must do this in pla...原创 2016-03-26 15:38:58 · 71 阅读 · 0 评论 -
leetcode: Remove Element
问题描述:Given an array and a value, remove all instances of that value in place and return the new length.Do not allocate extra space for another array, you must do this in place with constant memo...2016-03-26 16:02:23 · 101 阅读 · 0 评论 -
leetcode: Implement strStr()
问题描述:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.原问题链接:https://leetcode.com/problems/implement-strstr/ 问题分析...原创 2016-03-26 16:17:57 · 68 阅读 · 0 评论 -
leetcode: Divide Two Integers
问题描述:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.原问题链接:https://leetcode.com/problems/divide-two-integers/ 问题分析 这个问题和之...原创 2016-03-26 17:18:55 · 106 阅读 · 0 评论 -
leetcode: Substring with Concatenation of All Words
问题描述: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 onc...原创 2016-03-27 22:29:12 · 107 阅读 · 0 评论 -
leetcode : 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 it as the lowest p...原创 2016-03-27 22:58:21 · 132 阅读 · 0 评论 -
leetcode: Longest Valid Parentheses
问题描述: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-03-30 21:28:46 · 117 阅读 · 0 评论 -
leetcode: Search in Rotated Sorted Array
问题描述: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 ret...2016-03-30 22:00:42 · 121 阅读 · 0 评论 -
leetcode: Search for a Range
问题描述: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 fo...2016-03-30 22:46:09 · 100 阅读 · 0 评论 -
leetcode: Search Insert Position
问题描述: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 in the ...2016-03-30 23:35:41 · 82 阅读 · 0 评论 -
leetcode: 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 with the character '.'.A partially fill...原创 2016-03-31 10:51:05 · 158 阅读 · 0 评论 -
leetcode: 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 there will be only one unique solution. A sudoku...原创 2016-03-31 12:29:05 · 114 阅读 · 0 评论 -
leetcode: Count and Say
问题描述: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 is read off as "on...原创 2016-03-31 15:21:57 · 99 阅读 · 0 评论