刷题
文章平均质量分 62
明明77
这个作者很懒,什么都没留下…
展开
-
数据结构--字符串
字符串与子串、子序列C/C++标准库提供的字符串处理函数 strlen() 返回s的长度,不包括字符串结束符null strcmp(s1,s2) 比较两个字符串s1和s2是否相同。若s1与s2星等,返回1,若s1大于s2,返回整数,若s1小于s2,则返回负数 strcat(s1,s2) 将字符串s2连接到s1后,并返回s1 strcpy(s1,s2) 将s2复制给s1,转载 2017-12-15 00:00:06 · 288 阅读 · 0 评论 -
[leetcode] 7. Reverse Integer
题目链接:https://leetcode.com/problems/reverse-integer/Reverse digits of an integer.Example1: x = 123, return 321 Example2: x = -123, return -321思路注意溢出情况处理class Solution {public: int reverse(int x) {转载 2017-12-17 10:22:50 · 108 阅读 · 0 评论 -
[leetcode] 9. Palindrome Number
题目链接:https://leetcode.com/problems/palindrome-number/Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers. Some hints:Could negative integers be palindromes转载 2017-12-17 10:38:45 · 175 阅读 · 0 评论 -
[leetcode] 13. Roman to Integer
题目链接:https://leetcode.com/problems/roman-to-integer/Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.思路罗马数字总共有七个 即I(1)、V(5)、X(10)、L(50)、C(100)、转载 2017-12-17 10:48:20 · 128 阅读 · 0 评论 -
[leetcode] 14. Longest Common Prefix[leetcode] 14. Longest Common Prefix
题目链接:https://leetcode.com/problems/longest-common-prefix/Write a function to find the longest common prefix string amongst an array of strings.思路每次子串长度加1,直到子串不相等即是最大公共前缀class Solution {public: str转载 2017-12-17 10:56:55 · 130 阅读 · 0 评论 -
[leetcode] 20. Valid Parentheses
题目链接:https://leetcode.com/problems/valid-parentheses/Given a string containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[’ and ‘]’, determine if the input string is valid.The brackets must close in the转载 2017-12-17 11:09:44 · 153 阅读 · 0 评论 -
[leetcode] 21. Merge Two Sorted Lists
题目链接:https://leetcode.com/problems/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.思路转载 2017-12-17 15:03:51 · 133 阅读 · 0 评论 -
[leetcode] 26. Remove Duplicates from Sorted Array
题目链接:https://leetcode.com/problems/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 allo转载 2017-12-17 15:14:29 · 124 阅读 · 0 评论 -
[leetcode] 27. Remove Element
题目链接:https://leetcode.com/problems/remove-element/Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn’t matt转载 2017-12-17 15:21:59 · 126 阅读 · 0 评论 -
[leetcode] 28. Implement strStr()
思路找一个字符串中是否包含另一个字符串,并返回其位置。按照复杂的做那么就是KMPclass Solution {public: int strStr(string haystack, string needle) { int i = -1,len1 = haystack.size(),len2 = needle.size(); while(++i <= le转载 2017-12-17 15:33:03 · 173 阅读 · 0 评论 -
[leetcode] 35. Search Insert Position
题目链接:https://leetcode.com/problems/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 inserte转载 2017-12-18 09:40:26 · 128 阅读 · 0 评论 -
[Leetcode] 101.Symmetric Tree
[leetcode] 101. Symmetric Tree题目链接:https://leetcode.com/problems/symmetric-tree/Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tr转载 2018-01-03 17:05:47 · 181 阅读 · 0 评论 -
[Leetcode] 100.Same Tree
[leetcode] 100. Same Tree题目链接:https://leetcode.com/problems/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 struct转载 2017-12-25 18:57:11 · 178 阅读 · 0 评论 -
[Leetcode] 88.Merge Sorted Array
[leetcode] 88. Merge Sorted Array题目链接:https://leetcode.com/problems/merge-sorted-array/Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note: You may assume转载 2017-12-25 18:55:59 · 140 阅读 · 0 评论 -
[Leetcode]83.Remove Duplicates from Sorted List
[leetcode] 83. Remove Duplicates from Sorted List题目连接:https://leetcode.com/problems/remove-duplicates-from-sorted-list/Given a sorted linked list, delete all duplicates such that each element appear on转载 2017-12-25 18:48:32 · 127 阅读 · 0 评论 -
[Leetcode]2.Add Two Numbers
题目链接:https://leetcode.com/problems/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转载 2017-12-14 13:38:22 · 131 阅读 · 0 评论 -
[leetcode] 3. Longest Substring Without Repeating Characters
题目链接:https://leetcode.com/problems/longest-substring-without-repeating-characters/Given a string, find the length of the longest substring without repeating characters. For example, the longest substri转载 2017-12-15 08:36:19 · 125 阅读 · 0 评论 -
[leetcode] 4. Median of Two Sorted Arrays
题目链接: https://leetcode.com/problems/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 tim转载 2017-12-15 09:48:13 · 109 阅读 · 0 评论 -
[leetcode] 5. Longest Palindromic Substring
题目链接:https://leetcode.com/problems/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转载 2017-12-15 10:29:21 · 139 阅读 · 0 评论 -
[Leetcode]38--Count and Say
[leetcode] 38. Count and Say题目链接:https://leetcode.com/problems/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 “on转载 2017-12-25 18:34:12 · 145 阅读 · 0 评论 -
[Leetcode] 53--Maximum Subarray
[leetcode] 53. Maximum Subarray题目链接:https://leetcode.com/problems/maximum-subarray/Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, g转载 2017-12-25 18:36:39 · 148 阅读 · 0 评论 -
[leetcode]58 Length of Last Word
[leetcode] 58. Length of Last Word题目连接:https://leetcode.com/problems/length-of-last-word/Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of las转载 2017-12-25 18:38:33 · 140 阅读 · 0 评论 -
[Leetcode]66.Plus One
[leetcode] 66. Plus One题目链接:https://leetcode.com/problems/plus-one/Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most signifi转载 2017-12-25 18:40:17 · 131 阅读 · 0 评论 -
[Leetcode]67.Add Binary
[leetcode] 67. Add Binary题目链接:https://leetcode.com/problems/add-binary/Given two binary strings, return their sum (also a binary string).For example, a = “11” b = “1” Return “100”.字符串相加class Solutio转载 2017-12-25 18:42:22 · 136 阅读 · 0 评论 -
[Leetcode]69.Sqrt(x)
[leetcode] 69. Sqrt(x)题目链接:https://leetcode.com/problems/sqrtx/Implement int sqrt(int x).Compute and return the square root of x.思路二分查找,每次看中间的数平方是不是和当前数相等.class Solution {public: int mySqrt(int x)转载 2017-12-25 18:43:35 · 173 阅读 · 0 评论 -
[Leetcode]70.Climbing Stairs
[leetcode] 70. Climbing Stairs题目链接:https://leetcode.com/problems/climbing-stairs/You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how转载 2017-12-25 18:46:11 · 188 阅读 · 0 评论 -
[leetcode] 104. Maximum Depth of Binary Tree
[leetcode] 104. Maximum Depth of Binary Tree题目链接:https://leetcode.com/problems/maximum-depth-of-binary-tree/Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along th转载 2018-01-03 17:16:12 · 153 阅读 · 0 评论