![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
Scarlettliuu
这个作者很懒,什么都没留下…
展开
-
LeetCode13-Roman to Integer
在别处看到了有用STL中的map实现的,并且在LeetCode中运行通过:RuntimeMemory40ms10.8MB具体代码如下:class Solution {public: int romanToInt(string s) { int...原创 2019-03-26 16:31:42 · 98 阅读 · 0 评论 -
LeetCode14-Longest Common Prefix
方法一由两层循环嵌套:一个是遍历第一个字符串中的所有字符;另一个是遍历整个字符串向量,即一个一个比较,这种方法的空间复杂度小,但耗时较长RuntimeMemory12ms8.6MB具体代码如下:class Solution {public: string longestCommonPrefix(vector<string>& strs...原创 2019-03-27 19:46:27 · 92 阅读 · 0 评论 -
LeetCode20-Valid Parentheses
方法一RuntimeMemory8ms8.9MBclass Solution {public: bool isValid(string s) { stack<string> judge; if(s.substr(0,1)==")"||s.substr(0,1)=="]"||s.substr(0,1)=="}") ...原创 2019-03-28 16:35:33 · 100 阅读 · 0 评论 -
LeetCode21-Merge Two Sorted Lists
方法一首先新建一个头结点为header的空链表;比较l1和l2的每个数据域中的数值大小,将header指向数值较小的结点;若有一个链表已经归并完,直接将另一个链表链接在新生成的链表后即可。这种方法的效率如下:RuntimeMemory8ms8.9MB具体实现代码如下:/** * Definition for singly-linked list. * s...原创 2019-03-28 21:37:56 · 101 阅读 · 0 评论