![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
文章平均质量分 54
glory_lee
这个作者很懒,什么都没留下…
展开
-
LeetCode Algorithms No.1 Two Sums解题思路
Description:Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may原创 2017-02-24 09:34:40 · 284 阅读 · 0 评论 -
38.Count and Say
Description: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.原创 2017-05-17 16:21:51 · 187 阅读 · 0 评论 -
28. Implement strStr()
Description:Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.解题思路:在一个字符串当中查找是否包含另一个字符串,如果包含就返回该位置的索引。利用一个嵌套循环遍历haysta原创 2017-05-10 14:35:04 · 151 阅读 · 0 评论 -
27. Remove Element
Description: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 cons原创 2017-05-10 14:40:26 · 175 阅读 · 0 评论 -
35. Search Insert Position
Description: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 duplic原创 2017-05-10 15:56:01 · 164 阅读 · 0 评论 -
ZigZag Conversion
Description: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原创 2017-06-04 20:56:55 · 190 阅读 · 0 评论 -
算法机考模拟题题解(部分)
1000. 函数求值Description定义超级和函数F如下:F(0, n) = n,对于所有的正整数n..F(k, n) = F(k – 1, 1) + F(k – 1, 2) + … + F(k – 1, n),对于所有的正整数k和n. 请实现下面Solution类中计算F(k, n)的函数(1 class Solut原创 2017-06-27 22:19:44 · 432 阅读 · 0 评论 -
58. Length of Last Word
Description:Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.原创 2017-06-30 15:54:24 · 226 阅读 · 0 评论 -
17. Letter Combinations of a Phone Number
Description: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.原创 2017-06-30 16:06:41 · 238 阅读 · 0 评论 -
Algorithms exercise 8.8
Algorithms exercise8.8 In the EXACT 4SAT problem, the input is a set of clauses, each of which is a disjunction of exactly four literals, and such that each variable occurs at most once in each clau原创 2017-07-05 16:48:22 · 281 阅读 · 0 评论 -
26. Remove Duplicates from Sorted Array
Description: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原创 2017-04-26 14:17:38 · 180 阅读 · 0 评论 -
21. Merge Two Sorted Lists
description: 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.思路分析:一个有关链表的题目,意思大致是说把两个已经排列好顺序的链表合成为一个原创 2017-04-24 14:05:52 · 148 阅读 · 0 评论 -
3. Longest Substring Without Repeating Characters
Description:Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb",原创 2017-02-27 21:21:12 · 157 阅读 · 0 评论 -
2. Add Two Numbers
Description:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numb原创 2017-02-27 21:46:17 · 166 阅读 · 0 评论 -
5. Longest Palindromic Substring
Description:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "bab"Note: "aba" is also a原创 2017-03-07 10:00:56 · 174 阅读 · 0 评论 -
12. Integer to Roman
Description:iven an integer, convert it to a roman numeral.Input is guaranteed to be within the range from 1 to 3999.思路:题目还是算简单的吧,规定了1到3999的范围,我直接利用了贪心算法,每次都取最大的那个数,组合起来就解决了问题class Solution {原创 2017-04-07 16:30:46 · 202 阅读 · 0 评论 -
9. Palindrome Number
Description:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the int原创 2017-03-15 20:10:57 · 177 阅读 · 0 评论 -
13. Roman to Integer
Description:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.问题分析:这个题目的要求是给你一个罗马数字,让你把它转换成一个十进制数字。我们都知道罗马数字和十进制数字是有一些不同的,比如说在罗马数字原创 2017-03-15 20:42:56 · 501 阅读 · 0 评论 -
14. Longest Common Prefix
解题思路:这道题目的意思是说判断一系列字符串当中最长的前缀,在解题时只要逐一字符判断即可得到最长的相同前缀。class Solution {public: string longestCommonPrefix(vector& strs) { int n = strs.size(); string res; if(n == 0)return r原创 2017-04-14 14:56:25 · 165 阅读 · 0 评论 -
53. Maximum Subarray
Description:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [-2,1,-3,4,-1,2,1,-5,4],the contiguous subarr原创 2017-05-24 15:50:06 · 216 阅读 · 0 评论 -
20. Valid Parentheses
description:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" ar原创 2017-04-24 14:01:38 · 181 阅读 · 0 评论 -
100. Same Tree
Description: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原创 2017-06-28 14:09:36 · 214 阅读 · 0 评论