![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode刷题
Liberalspirit
这个作者很懒,什么都没留下…
展开
-
leetcode12
// 注意位置是在class 的外部// unordered_map的内部顺序可能和初始化的时候不一样const pair<int, string> hmap[] = { {1000, "M"}, {900, "CM"}, {500, "D"}, {400, "CD"}, {100, "C"}, {90, "XC"}, {50, "L"}, {40, "XL"}, .原创 2021-09-22 14:36:06 · 112 阅读 · 0 评论 -
leetcode 9
//1.常规方法class Solution {public: int isPalindrome(int x) { int temp=x; if(x<0) return false; int reverse=0; while(x){ //overflow if(reverse>INT_MAX/10)return false; int digit=x.原创 2021-09-21 15:45:48 · 117 阅读 · 0 评论 -
leetcode 5
//第一种方法:动态规划dpclass Solution {public: string longestPalindrome(string s) { int n=s.length();//s的长度 0-n-1 if(n<2)return s;//剪枝 int dp[1005][1005]={0};//设置hash表记录s[i][j]是否是回文串 // memset(dp,0,sizeof(dp)) //初.原创 2021-09-18 10:39:01 · 111 阅读 · 0 评论 -
leetcode1-3
//1. 两数之和//时间复杂度o(n)class Solution {public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int,int> hashMap; int n=nums.size(); for(int i=0;i<n;i++){ auto it=hashMap.find(t.原创 2021-09-16 15:44:48 · 84 阅读 · 0 评论