![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
文章平均质量分 50
ambihan
这个作者很懒,什么都没留下…
展开
-
7.旋转数字
Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321原创 2014-09-26 18:46:20 · 539 阅读 · 0 评论 -
6.字符串的反N型曲折转换
找出规律即可 #include #include using namespace std; class Solution { public: string convert(string s, int nRows) { if (nRows <= 1) return s; string result; for (int i = 0; i < nRows; ++i) { i原创 2014-09-26 18:32:12 · 532 阅读 · 0 评论 -
9.判断一个数字是否为回文
#include using namespace std; class Solution { public: bool isPalindrome(int x) { if (x < 0) return false; int m = x, n = 1; while (m /= 10) n *= 10; m = x; while (m) { if (m / n != x原创 2014-09-26 19:07:32 · 512 阅读 · 0 评论 -
4.用链表实现两个大数相加
所有数字都用逆向链表表示原创 2014-09-26 16:20:47 · 1020 阅读 · 0 评论 -
1.无序数组中找出两个数使其和等于给定值
碰到这种类似题目可以根据条件不同写出不同时间复杂度的代码 1原创 2014-09-25 19:23:47 · 2104 阅读 · 0 评论 -
12.阿拉伯数字转化为罗马数字1-3999
#include #include using namespace std; class Solution { public: string intToRoman(int num) { string result; if (num 3999) return result; char One[] = { 'I', 'X', 'C', 'M' }; char Five[] =原创 2014-10-06 18:17:17 · 678 阅读 · 0 评论 -
13.罗马数字转化为阿拉伯数字1-3999
#include #include #include using namespace std; class Solution { public: int romanToInt(string s) { int result = 0; unordered_map Roman; Roman['I'] = 1; Roman['V'] = 5; Roman['X'] = 10;原创 2014-10-06 18:33:31 · 615 阅读 · 0 评论 -
11. 坐标轴容器盛水问题
任意取两条线与x坐标轴构成容器的最大容量原创 2014-10-06 17:07:49 · 611 阅读 · 0 评论 -
14.一组字符串的最长公共前缀
#include #include #include using namespace std; class Solution { public: string longestCommonPrefix(vector &strs) { string result; if (strs.empty()) return result; int i = 0; while (true)原创 2014-10-06 19:13:25 · 448 阅读 · 0 评论