随笔分类 - LeetCode
摘要:题目要求:Search in Rotated Sorted ArraySuppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 ...
阅读全文
摘要:题目描述:Longest Valid ParenthesesGiven a string containing just the characters'('and')', find the length of the longest valid (well-formed) parentheses s...
阅读全文
摘要:题目要求:Substring with Concatenation of All WordsYou are given a string,S, and a list of words,L, that are all of the same length. Find all starting indi...
阅读全文
摘要:题目要求:Divide Two IntegersDivide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.分析:不能用乘、除和取余,则只能...
阅读全文
摘要:题目要求:Implement strStr()Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Jav...
阅读全文
摘要:题目要求:Remove ElementGiven an array and a value, remove all instances of that value in place and return the new length.The order of elements can be chan...
阅读全文
摘要:题目描述:Remove Duplicates from Sorted ArrayGiven a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new ...
阅读全文
摘要:题目描述:Reverse Nodes in k-GroupGiven a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is ...
阅读全文
摘要:题目描述:Swap Nodes in PairsGiven a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list...
阅读全文
摘要:题目要求:Merge k Sorted ListsMergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.AnalysisThe simplest solution...
阅读全文
摘要:题目描述:Generate ParenthesesGivennpairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, givenn= 3, ...
阅读全文
摘要:题目描述:Valid ParenthesesGiven a string containing just the characters'(',')','{','}','['and']', determine if the input string is valid.The brackets must...
阅读全文
摘要:题目描述:Remove Nth Node From End of ListGiven a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list:...
阅读全文
摘要:题目描述:4SumGiven an arraySofnintegers, are there elementsa,b,c, anddinSsuch thata+b+c+d= target? Find all unique quadruplets in the array which gives th...
阅读全文
摘要:题目描述:Letter Combinations of a Phone NumberGiven a digit string, return all possible letter combinations that the number could represent.A mapping of d...
阅读全文
摘要:题目描述:3Sum ClosestGiven an arraySofnintegers, find three integers inSsuch that the sum is closest to a given number, target. Return the sum of the thre...
阅读全文
摘要:题目描述:3SumGiven an arraySofnintegers, are there elementsa,b,cinSsuch thata+b+c= 0? Find all unique triplets in the array which gives the sum of zero.No...
阅读全文
摘要:题目描述:Longest Common PrefixWrite a function to find the longest common prefix string amongst an array of strings.代码如下:class Solution {public: string...
阅读全文
摘要:题目描述:Roman to IntegerGiven a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.分析:① 输入为VII,则数字为V + I +...
阅读全文
摘要:题目描述:Integer to RomanGiven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.罗马数字的计数方法:基本字符IVXLCDM相应...
阅读全文