上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 20 下一页
摘要: class Solution { public: int romanToInt(string s) { int res = 0; unordered_map<char, int> m{{'I', 1}, {'V', 5}, {'X', 10}, {'L', 50}, {'C', 100}, {'D' 阅读全文
posted @ 2017-02-04 23:38 王坤1993 阅读(117) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: string intToRoman(int num) { string res = ""; vector<int> val{1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1}; vector<s 阅读全文
posted @ 2017-02-04 00:17 王坤1993 阅读(170) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: bool isMatch(string s, string p) { int m = s.size(), n = p.size(); vector<vector<bool>> dp(m + 1, vector<bool>(n + 1, false)) 阅读全文
posted @ 2017-02-01 21:07 王坤1993 阅读(154) 评论(0) 推荐(0) 编辑
摘要: class Solution {public: bool isPalindrome(int x) { //negative number if(x < 0) return false; int len = 1; while(x / len >= 10) len *= 10; while(x > 0) 阅读全文
posted @ 2017-02-01 21:03 王坤1993 阅读(150) 评论(0) 推荐(0) 编辑
摘要: public class Solution { public int myAtoi(String str) { if (str.isEmpty()) return 0; int sign = 1, base = 0, i = 0, n = str.length(); while (i < n && 阅读全文
posted @ 2017-02-01 00:26 王坤1993 阅读(180) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int reverse(int x) { int res = 0; while (x != 0) { int t = res * 10 + x % 10; if (t / 10 != res) return 0; res = t; x /= 10; 阅读全文
posted @ 2017-01-30 23:54 王坤1993 阅读(156) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: string convert(string s, int nRows) { if (nRows <= 1) return s; string res = ""; int size = 2 * nRows - 2; for (int i = 0; i 阅读全文
posted @ 2017-01-29 20:24 王坤1993 阅读(239) 评论(0) 推荐(0) 编辑
摘要: // Time complexity O(n*n) class Solution { public: string longestPalindrome(string s) { int startIdx = 0, left = 0, right = 0, len = 0; for (int i = 0 阅读全文
posted @ 2017-01-29 20:20 王坤1993 阅读(147) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) { int total = nums1.size() + nums2.size(); if (total % 阅读全文
posted @ 2017-01-29 20:19 王坤1993 阅读(134) 评论(0) 推荐(0) 编辑
摘要: class Solution { public: int lengthOfLongestSubstring(string s) { int m[256] = {0}, res = 0, left = 0; for (int i = 0; i < s.size(); ++i) { if (m[s[i] 阅读全文
posted @ 2017-01-29 20:18 王坤1993 阅读(125) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 20 下一页