摘要:        
1 //用到了贪心思想 2 class Solution 3 { 4 public: 5 int a[13] = {1,4,5,9,10,40,50,90,100,400,500,900,1000}; 6 string b[13] = {"I","IV","V","IX","X","XL","L",    阅读全文
posted @ 2020-03-15 18:23
Jinxiaobo0509
阅读(175)
评论(0)
推荐(0)
        
            
        
        
摘要:        
1 //双指针算法 2 class Solution 3 { 4 public: 5 int maxArea(vector<int>& height) 6 { 7 int n = height.size(); 8 int Area = 0; 9 int l = 0,r = n - 1; 10 whi    阅读全文
posted @ 2020-03-15 18:22
Jinxiaobo0509
阅读(87)
评论(0)
推荐(0)
        
            
        
        
摘要:        
1 class Solution 2 { 3 public: 4 bool isPalindrome(int x) 5 { 6 if(x < 0) return false; 7 vector<int> nums; 8 while(x) 9 { 10 nums.push_back(x % 10);     阅读全文
posted @ 2020-03-15 18:20
Jinxiaobo0509
阅读(98)
评论(0)
推荐(0)
        
            
        
        
摘要:        
1 class Solution 2 { 3 public: 4 int myAtoi(string str) 5 { 6 long long res = 0; 7 bool flag = true; 8 bool jisuan = false; 9 for(int i = 0;i < str.si    阅读全文
posted @ 2020-03-15 18:17
Jinxiaobo0509
阅读(133)
评论(0)
推荐(0)
        
            
        
        
摘要:        
1 //注意x = abs(x) x->[-2147483648,2147483647] 2 class Solution 3 { 4 public: 5 int reverse(int x) 6 { 7 bool f = false; 8 long long res = 0; 9 if(x < 0    阅读全文
posted @ 2020-03-15 18:16
Jinxiaobo0509
阅读(133)
评论(0)
推荐(0)
        
            
        
        
摘要:        
1 //找规律题 等差数列 2m-2 2 class Solution 3 { 4 public: 5 string convert(string s, int m) 6 { 7 if(m == 1) return s; 8 int n = s.size(); 9 string res; 10 fo    阅读全文
posted @ 2020-03-15 18:14
Jinxiaobo0509
阅读(128)
评论(0)
推荐(0)
        
            
        
        
摘要:        
1 //左右同时走,如果相等,更新最大值 2 class Solution 3 { 4 public: 5 string longestPalindrome(string s) 6 { 7 int res = 0; 8 string str; 9 for(int i = 0;i < s.size()    阅读全文
posted @ 2020-03-15 18:12
Jinxiaobo0509
阅读(96)
评论(0)
推荐(0)
        
            
        
        
摘要:        
1 //双指针算法模板+哈希表 2 class Solution 3 { 4 public: 5 int lengthOfLongestSubstring(string s) 6 { 7 unordered_map<char,int> nums; 8 int res = 0; 9 for(int i    阅读全文
posted @ 2020-03-15 18:11
Jinxiaobo0509
阅读(123)
评论(0)
推荐(0)
        
            
        
        
摘要:        
1 class Solution 2 { 3 public: 4 ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) 5 { 6 ListNode* dummy = new ListNode(-1); 7 ListNode* pre = dummy    阅读全文
posted @ 2020-03-15 18:10
Jinxiaobo0509
阅读(119)
评论(0)
推荐(0)
        
            
        
        
摘要:        
https://leetcode-cn.com/problems/two-sum/ 1 //哈希表 2 class Solution 3 { 4 public: 5 vector<int> twoSum(vector<int>& nums, int target) 6 { 7 unordered_m    阅读全文
posted @ 2020-03-15 17:33
Jinxiaobo0509
阅读(100)
评论(0)
推荐(0)
        
                    
                
浙公网安备 33010602011771号