上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 87 下一页
摘要: 统计每个值所能获得的点数 dp 从终态考虑转移方程!!! dp[i][0]表示第i个数保留 dp[i][1]表示删除第i个数 dp[n][0] = dp[n - 1][1]; dp[n][1] = max(dp[n - 2][0], dp[n - 2][1]) + a[n]; class Solut 阅读全文
posted @ 2021-05-05 09:09 WTSRUVF 阅读(75) 评论(0) 推荐(0)
摘要: class Solution { public: int reverse(int x) { // cout << 1111 << endl; long long ret = 0; long long y = x; int f = 0; if(y < 0) f = 1, y = -y; // cout 阅读全文
posted @ 2021-05-03 16:30 WTSRUVF 阅读(66) 评论(0) 推荐(0)
摘要: /* // Definition for Employee. class Employee { public: int id; int importance; vector<int> subordinates; }; */ class Solution { public: int vis[10010 阅读全文
posted @ 2021-05-02 17:23 WTSRUVF 阅读(77) 评论(0) 推荐(0)
摘要: 用map统计边缘即可 最后求出哪个边缘出现次数cnt最多 返回n - cnt即可 class Solution { public: map<int, int> vis; set<int> s; int leastBricks(vector<vector<int>>& wall) { int n = 阅读全文
posted @ 2021-05-02 16:51 WTSRUVF 阅读(58) 评论(0) 推荐(0)
摘要: map映射一下就好了 class Solution { public: // const int maxn = 30010; int vis[30010]; map<int, int> M; int singleNumber(vector<int>& nums) { int n = nums.siz 阅读全文
posted @ 2021-04-30 16:33 WTSRUVF 阅读(70) 评论(0) 推荐(0)
摘要: 因为数据太大,但数据量少,因此可以用map先建立映射关系 再用二维set,其中set[i]表示第i个石块所能跳的距离数组 二维vector会超时,set去重就可以了 然后遍历每个石块,并求出其所能到达石块 所能跳的距离 最后判断第n - 1个石块是否有能跳的步数即可 class Solution { 阅读全文
posted @ 2021-04-29 16:45 WTSRUVF 阅读(62) 评论(0) 推荐(0)
摘要: oj上的编译器严格一点 判断的时候用 tmp == (int)tmp 不大行 用的tmp == (floor)tmp 效果一样 class Solution { public: int a[100100]; bool judgeSquareSum(int c) { long long i; for( 阅读全文
posted @ 2021-04-28 16:58 WTSRUVF 阅读(57) 评论(0) 推荐(0)
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2021-04-27 17:28 WTSRUVF 阅读(68) 评论(0) 推荐(0)
摘要: 抽象为把序列分成D段,求和最大的段的最小值 下界为最大值,上界为序列和,二分结果,每次去验证是否合适即可 class Solution { public: int shipWithinDays(vector<int>& weights, int D) { int total = 0; int max 阅读全文
posted @ 2021-04-26 17:54 WTSRUVF 阅读(91) 评论(0) 推荐(0)
摘要: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), rig 阅读全文
posted @ 2021-04-25 17:20 WTSRUVF 阅读(45) 评论(0) 推荐(0)
上一页 1 ··· 34 35 36 37 38 39 40 41 42 ··· 87 下一页