![](https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode题目
d4snap
The most terrible person in the world is yourself.
展开
-
Leetcode 3 Longest Substring Without Repeating Characters
3 Longest Substring Without Repeating Characters最长的没有重复的连续子串题目描述在字符串中间寻找最长的没有重复元素的字串, 如: 对于asdac 结果是 sdac思路维持一个滑动窗口建立头指针,尾指针,分别表示窗口的开始和结束位置。从字符串头部开始。 将尾指针前移,把当前尾指针指向的元素加入窗口,如果尾指针遇到...原创 2018-07-29 10:29:09 · 197 阅读 · 1 评论 -
Leetcode 13. Roman to Integer
13. Roman to Integer题目描述将罗马数字转化为十进制数字思路因为涉及到加法和减法,VI IV/IX两种情况如果遇到小的在左边,大的在右边那就是一次减法代码class Solution {public: int romanToInt(string s) { map<char, int> hm; hm['I'] = 1; ...原创 2018-11-12 14:43:46 · 146 阅读 · 0 评论 -
Leetcode 12. Integer to Roman
12. Integer to Roman题目描述Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.Symbol ValueI 1V 5X 10L 50C ...原创 2018-10-31 20:36:00 · 125 阅读 · 0 评论 -
Leetcode 10. Regular Expression Matching
10. Regular Expression Matching题目描述Given an input string (s) and a pattern §, implement regular expression matching with support for ‘.’ and '’.给出一个字符串s和一个正则模式p,实现一个支持’.’,’'的正则表达式匹配函数‘.’ Matches ...原创 2018-10-14 18:49:27 · 117 阅读 · 0 评论 -
Leetcode 11. Container With Most Water
11. 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 i...原创 2018-10-17 22:09:49 · 124 阅读 · 0 评论 -
Leetcode 9. Palindrome Number
9. Palindrome Number题目描述判断一个整数是不是回文(即为正反顺序念相同的字符串)思路负数当然是没可能了;正数的情况先转换成字符串,然后头尾比较代码javascript/** * @param {number} x * @return {boolean} */var isPalindrome = function(x) { if (x &lt; 0...原创 2018-09-28 11:11:07 · 118 阅读 · 0 评论 -
Leetcode 8. String to Integer (atoi)
8. String to Integer (atoi)题目描述实现atoi首先忽略前导空白符号可选正负号数字数值越界返回INT_MAX (2^31 − 1) 或者 INT_MIN (−2^31)其他非法情况一律返回0思路感觉就是很多条件然后判断分别处理这样子进行,首先如果是空白就忽略到第一个非空白,然后是可选的正负号,然后数字的话就继续,一旦遇到字母等其他情况就停止。代码//...原创 2018-09-20 14:11:15 · 130 阅读 · 0 评论 -
Leetcode 7. Reverse Integer
7. Reverse Integer题目描述讲一个数字高位低位反转,返回新的数字 如果新的数字超出范围则返回0思路比较简单的思路,高低位置反转也就意味着最低位将成为最高,那么我们每次取出一位最低存入新数中,然后再取的就接在他后面,知道旧数字取完。代码class Solution {public: int reverse(int x) { ...原创 2018-09-13 10:00:29 · 120 阅读 · 0 评论 -
Leetcode 6. ZigZag Conversion
6. ZigZag Conversion题目描述将一个字符串以Z字形输出,这么说可能不太清楚,看一下下面的例子就知道了,给定一个源字符串,然后和Z字的大小(就是每一笔用几个字母组成),输出Z字形的字符串。源字符串 Z字大小 PAYPALISHIRING size:3输出下面图形按行排列的顺序 P A H N A P L S I I G Y...原创 2018-09-10 19:37:37 · 130 阅读 · 0 评论 -
Leetcode 4. Median of Two Sorted Arrays
4. Median of Two Sorted Arrays问题描述求两个有序的数组合并后的中位数思路主要思路就是从两个数组数组头开始提取元素,然后比较大小,将较小者存入新数组,继续取一个元素然后重复比较,选较小的放入新数组。直到其中达到了中位数的位置或者一个已经空了,那就直接从另一个取元素直到中位数位置。1 如果某数组为空,则返回另一个数组的中位数 2 如果两者都不...原创 2018-09-05 14:43:18 · 111 阅读 · 0 评论 -
Leetcode 5. Longest Palindromic Substring
最长回文子串问题描述给一个字符串,寻找到他的最长的回文子串。 回文:即正反顺序读取结果相同的字符串,如:'aba', 'af4fa'这样子的字符串。 现给出指定字符串,要求返回其最长的回文子串,如有多个长度相等,则返回其中任意一个即可。解题思路对于字符串s用一个f(i,j)表示从i到j是否回文 i == j, 那么f(i,j) = 1 2. i + 1 ==...原创 2018-08-02 15:17:26 · 123 阅读 · 0 评论 -
Leetcode 14. Longest Common Prefix
14. Longest Common Prefix题目描述Write a function to find the longest common prefix string amongst an array of strings.写一个函数找到一组字符串的最长公共前缀字符串If there is no common prefix, return an empty string “”.如果...原创 2018-11-22 16:40:59 · 156 阅读 · 0 评论