ACM
文章平均质量分 62
荣耀王者荣耀
这个作者很懒,什么都没留下…
展开
-
正则表达式匹配(Regular Expression Matching)
https://leetcode.com/problems/regular-expression-matching/description/题目大意:给正则表达式p,一个字符串s,若正则表达式能匹配成功则为true 否则为false,其中‘*’表示*前的字母可重复0或多次,‘.’可以匹配任意字符 如 ab a*ab true原创 2017-10-10 21:36:19 · 414 阅读 · 0 评论 -
罗马数字变数字(Roman to Integer)
https://leetcode.com/problems/roman-to-integer/description/上一题的反向出题:思路:既然知道罗马数字里的字符都只表示千级,百级,十级.....故一个字符一个字符的扫描,将其所对应的数字相加即可。注意小的在大的前面是相减实现:想用c++的map容器,出错。。。大神指导一下map初始化:#include#include#in原创 2017-10-21 20:45:24 · 242 阅读 · 0 评论 -
含水最多的容器(Container With Most Water)
https://leetcode.com/problems/container-with-most-water/description/题目大意:给n个数,a1,a2....ai....an,每个数对应一个坐标(i,ai),对每个坐标与(i,0)做线段,这n个线段哪两个线段与x轴构成的容器装水最多?思路:容器容量由两个线段最短的长度,和底决定。 简单暴力:就是算出两两原创 2017-10-12 15:51:06 · 302 阅读 · 0 评论 -
最长公共前缀(Longest Common Prefix)
https://leetcode.com/problems/longest-common-prefix/description/题目大意:Write a function to find the longest common prefix string amongst an array of strings.在一组字符串中找最长公共前缀。思路:vector结构体,最简单的思路就是最长前原创 2017-10-23 20:32:25 · 759 阅读 · 0 评论 -
将数字转换为罗马数字(Integer to Roman)
https://leetcode.com/problems/integer-to-roman/description/题目大意:将数字转化为罗马数字(数字范围1--3999)思路:罗马数字的构成 1(I) 5(V) 10(X) 50(L) 100(C) 500(D) 1000(M) 以上重复几次就是几倍,如20(XX)原创 2017-10-15 13:52:32 · 2156 阅读 · 0 评论 -
三个数之和(3sum)
https://leetcode.com/problems/3sum/description/题目描述:给一个含n个整数的数组,找出不重复的所有的三个数相减为0的三元组For example, given array S = [-1, 0, 1, 2, -1, -4],A solution set is:[ [-1, 0, 1], [-1, -1, 2]]vecto原创 2017-11-10 16:15:21 · 452 阅读 · 0 评论 -
4sums
https://leetcode.com/problems/4sum/description/For example, given array S = [1, 0, -1, 0, -2, 2], and target = 0.A solution set is:[ [-1, 0, 0, 1], [-2, -1, 1, 2], [-2, 0, 0, 2]]思想: 找出两个数的...原创 2018-03-08 16:34:15 · 187 阅读 · 0 评论