=====LeetCode=====
黄焖鸡米饭啊
嗯。
展开
-
移除元素
题目:给定一个数组 nums和一个值 val,你需要原地移除所有数值等于val的元素,返回移除后数组的新长度。不要使用额外的数组空间,你必须在原地修改输入数组并在使用 O(1) 额外空间的条件下完成。元素的顺序可以改变。你不需要考虑数组中超出新长度后面的元素。示例 1:给定 nums = [3,2,2,3], val = 3,函数应该返回新的长度 2, 并且 nums...原创 2019-10-14 22:26:15 · 202 阅读 · 0 评论 -
删除排序链表中的重复元素
题目:给定一个排序链表,删除所有重复的元素,使得每个元素只出现一次。示例1:输入: 1->1->2输出: 1->2示例2:输入: 1->1->2->3->3输出: 1->2->3思路:使用双指针法,p1指向一个节点,p2指向下一个和p1不重复的节点,将p1的next指向p2,p1和p2之间重复的节点即被删除,重复这...原创 2019-10-13 17:39:36 · 300 阅读 · 0 评论 -
Range_Sum_Query_Mutable
题目描述:Given an integer array nums, find the sum of the elements between indices i and j(i ≤ j),inclusive.The update(i, val) function modifies nums by updating the element at index i to val.Example:Give...原创 2018-02-26 21:59:27 · 94 阅读 · 0 评论 -
One_Edit_Distance
题目描述:Given two strings S and T, determine if they are both one edit distance apart.(判断两个字串能否只进行一次操作就使两字串相等。)思路:(1)如果两个字串的长度之差大于1,那么就不可能只通过一次操作使两字串相等,故直接返回false。 (2)如果两个字串的长度之差等于1,那么两个字串在原创 2018-02-15 18:51:11 · 171 阅读 · 0 评论 -
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 entire input s原创 2018-01-18 11:28:30 · 312 阅读 · 0 评论 -
Reverse_Nodes_in_kGroup
题目描述:Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list.If the原创 2018-01-05 13:35:02 · 177 阅读 · 0 评论 -
Merge_k_Sorted_Lists
题目描述:Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.(合并k个有序链表).思路:普通思路就是把每条链表单拿出来遍历,然后将链表中的元素一个一个往结果集中按大小放,直到所有链表都被遍历完。如果有n条链表,每个list的最大长度是m,假如使用,时间复...原创 2017-12-29 21:10:38 · 176 阅读 · 0 评论 -
Clone_Graph
题目描述:Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for eac原创 2017-12-20 10:19:06 · 214 阅读 · 0 评论 -
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 course 1, which is expressed as原创 2017-12-19 09:40:43 · 189 阅读 · 0 评论 -
Course_Schedule
题目描述: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 course 1, which is expressed as原创 2017-12-17 16:21:45 · 194 阅读 · 0 评论 -
Redundant_Connection_II
题目描述:In this problem, a rooted tree is a directed graph such that, there is exactly one node (the root) for which all other nodes are descendants of this node, plus every node has exactly one parent原创 2017-12-15 11:26:40 · 353 阅读 · 2 评论 -
Redundant_Connection
题目描述:In this problem, a tree is an undirected graph that is connected and has no cycles.The given input is a graph that started as a tree with N nodes (with distinct values 1, 2, ..., N), with one a原创 2017-12-12 15:03:15 · 235 阅读 · 0 评论 -
Create_Maximum_Number
题目描述:Given two arrays of length m and n with digits 0-9 representing two numbers. Create the maximum number of length k <= m + n from digits of the two. The relative order of the digits from the sam原创 2017-12-06 19:02:05 · 177 阅读 · 0 评论 -
Best Time to Buy and Sell Stock III
题目描述:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note:You m原创 2017-11-24 21:52:08 · 270 阅读 · 0 评论 -
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 "()", w原创 2017-10-30 19:29:38 · 210 阅读 · 0 评论 -
Maximal_Rectangle
题目描述:Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.For example, given the following matrix:1 0 1 0 01 0 1 1 11 1 1 1原创 2017-11-07 18:33:39 · 267 阅读 · 0 评论 -
Trapping Rain Water
题目描述:Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3原创 2017-11-15 20:59:18 · 165 阅读 · 0 评论 -
Largest_Rectangle_in_Histogram
题目描述:Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram.(给定n个非负整数表示柱状图的条高如果每个条的宽度为1原创 2017-10-15 19:24:50 · 236 阅读 · 0 评论 -
Basic_Calculator
题目描述:Implement a basic calculator to evaluate a simple expression string.The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and emp原创 2017-10-09 16:58:12 · 168 阅读 · 0 评论 -
Maximum_Product_of_Word_Lengths
题目描述:Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower ca原创 2017-09-29 20:58:31 · 171 阅读 · 0 评论 -
Single_Number_III
题目描述:Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice.Find the two elements that appear only once.For example:原创 2017-09-22 22:01:20 · 159 阅读 · 0 评论 -
Single_Number_II
题目描述: Given an array of integers, every element appears three times except for one, which appears exactly once. Find that single one. Note: Your algorithm should have a linear runtime co原创 2017-09-21 12:26:46 · 143 阅读 · 0 评论 -
Single_Number
题目描述: Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime complexity. Could you implement i原创 2017-09-21 12:23:57 · 145 阅读 · 0 评论 -
Repeated_DNA_Sequences
题目描述: All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: "ACGAATTCCG". When studying DNA, it is sometimes useful to identify repeated sequences within t原创 2017-09-19 14:59:57 · 267 阅读 · 0 评论 -
Integer_Replacement
题目描述: Given a positive integer n and you can do operations as follow: If n is even, replace n with n/2. If n is odd, you can replace n with either n + 1 or n - 1. What is the minim原创 2017-09-18 19:13:41 · 399 阅读 · 0 评论 -
Subsets位运算版
题目描述:Given a set of distinct integers, S, return all possible subsets.Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets.原创 2017-09-18 12:39:03 · 588 阅读 · 0 评论 -
Bitwise_AND_of_Numbers_Range
题目描述: Given a range [m, n] where 0 return the bitwise AND of all numbers in this range, inclusive. For example, given the range [5, 7], you should return 4. (求m和n二进制编码中,相同的前缀 .)思路:将两个数同时向右移原创 2017-09-18 12:34:50 · 346 阅读 · 0 评论 -
Number_of_Longest_Increasing_Subsequence
题目描述:Given an unsorted array of integers, find the number of longest increasing subsequence.Example 1:Input: [1,3,5,4,7]Output: 2Explanation: The two longest increasing subsequence are [1,原创 2017-09-15 19:16:15 · 345 阅读 · 0 评论 -
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 or a regular expression string contain原创 2017-09-12 11:28:47 · 270 阅读 · 0 评论 -
Implement_Trie_(Prefix_Tree)
题目描述:Implement a trie(单词查找树:利用字符串的公共前缀来节约存储空间) with insert, search, and startsWith methods.Note: You may assume that all inputs are consist of lowercase letters a-z.思路:全在注释里。public class Im原创 2017-09-11 12:24:40 · 332 阅读 · 0 评论 -
Unique_Paths_II
题目描述: Follow up for "Unique Paths": Now consider if some obstacles(障碍) are added to the grids. How many unique paths would there be? An obstacle and empty space is marked as 1 and 0 r原创 2017-09-08 16:30:37 · 273 阅读 · 0 评论 -
Unique_Paths
题目描述: A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying原创 2017-09-08 16:28:11 · 331 阅读 · 0 评论 -
Combination_Sum_II
题目描述: Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. Each number in C may only be used once in the原创 2017-09-07 12:03:34 · 235 阅读 · 0 评论 -
Combination_Sum
题目描述: Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T. The same repeated number may b原创 2017-09-07 11:16:57 · 282 阅读 · 0 评论 -
Palindrome_Partitioning
题目描述:Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.(给定一个字符串S,将s划分为每个子串是回文。返回所有可能的回文划分S.)For example, g原创 2017-09-04 16:51:43 · 277 阅读 · 0 评论 -
Unique_Substrings_in_Wraparound_Strin
题目描述: Consider the string s to be the infinite wraparound string of "abcdefghijklmnopqrstuvwxyz", so s will look like this: "...zabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcd....".原创 2017-09-03 18:39:37 · 227 阅读 · 0 评论 -
Word_Ladder
题目描述: Given two words (start and end), and a dictionary, find the length of shortest transformation sequence from start to end, such that: Only one letter can be changed at a time Eac原创 2017-08-31 17:59:22 · 348 阅读 · 0 评论 -
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. (给定一个包含"X"和"O"的二维板,捕捉所有被X包围的...原创 2017-08-29 19:43:34 · 322 阅读 · 0 评论 -
Shopping_Offers
题目描述: In LeetCode Store, there are some kinds of items to sell. Each item has a price. However, there are some special offers, and a special offer consists of one or more different kinds原创 2017-08-27 11:20:52 · 242 阅读 · 0 评论 -
Maximum_Length_of_Pair_Chain
题目描述: You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow another pair (a, b) if and only if b原创 2017-08-23 16:37:19 · 195 阅读 · 0 评论