摘要: 动态规划 背包问题 状态表示 1.集合:所有只考虑前i个物品,且总体积不大于j的所有选法 2.属性:MAX 2.1 去掉k个物品i 2.2 求MAX,f【i 1】【j k v】 2.3 再加回来k个物品i 状态计算:集合的划分 1. 0 1背包(Acwing 2) 朴素做法 阅读全文
posted @ 2020-03-06 14:27 景云ⁿ 阅读(339) 评论(0) 推荐(0) 编辑
摘要: 链接:https://leetcode-cn.com/problems/ba-shu-zu-pai-cheng-zui-xiao-de-shu-lcof/ 代码: class Solution { public: static bool cmp(int a, int b) { auto as = t 阅读全文
posted @ 2020-03-05 14:14 景云ⁿ 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 链接:https://leetcode-cn.com/problems/shu-zi-xu-lie-zhong-mou-yi-wei-de-shu-zi-lcof/ 思路: 1.确定是几位数 2.确定是第几个数 3.确定是第几位 代码: class Solution { public: int fi 阅读全文
posted @ 2020-03-05 13:55 景云ⁿ 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 链接:https://leetcode-cn.com/problems/1nzheng-shu-zhong-1chu-xian-de-ci-shu-lcof/ 代码: class Solution { public: int countDigitOne(int n) { vector<int> nu 阅读全文
posted @ 2020-03-04 14:08 景云ⁿ 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 链接:https://leetcode-cn.com/problems/lian-xu-zi-shu-zu-de-zui-da-he-lcof/submissions/ 代码: class Solution { public: int maxSubArray(vector<int>& nums) { 阅读全文
posted @ 2020-03-04 13:49 景云ⁿ 阅读(133) 评论(0) 推荐(0) 编辑
摘要: 链接:https://leetcode-cn.com/problems/shu-ju-liu-zhong-de-zhong-wei-shu-lcof/submissions/ 代码: class MedianFinder { public: priority_queue<int> max_heap; 阅读全文
posted @ 2020-03-03 21:17 景云ⁿ 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 链接:https://leetcode-cn.com/problems/zui-xiao-de-kge-shu-lcof/submissions/ 代码: class Solution { public: vector<int> getLeastNumbers(vector<int>& arr, i 阅读全文
posted @ 2020-03-03 20:56 景云ⁿ 阅读(78) 评论(0) 推荐(0) 编辑
摘要: 链接:https://leetcode-cn.com/problems/shu-zu-zhong-chu-xian-ci-shu-chao-guo-yi-ban-de-shu-zi-lcof/ 思路: cnt记录个数,val记录值;遍历数组,若等于val,则cnt++,否则cnt--,若cnt为0, 阅读全文
posted @ 2020-03-02 21:52 景云ⁿ 阅读(84) 评论(0) 推荐(0) 编辑
摘要: 链接:https://leetcode-cn.com/problems/zi-fu-chuan-de-pai-lie-lcof/ 代码: class Solution { public: vector<string> permutation(string s) { vector<string> re 阅读全文
posted @ 2020-03-02 21:43 景云ⁿ 阅读(109) 评论(0) 推荐(0) 编辑
摘要: 链接:https://leetcode-cn.com/problems/xu-lie-hua-er-cha-shu-lcof/ 代码: /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode 阅读全文
posted @ 2020-03-01 15:19 景云ⁿ 阅读(130) 评论(0) 推荐(0) 编辑