摘要: 第一题 题目链接:https://leetcode.cn/problems/zui-xiao-de-kge-shu-lcof/ 个人题解:设置优先队列,存入 \(k\) 个值,然后弹出即可 代码: class Solution { public: vector<int> getLeastNumber 阅读全文
posted @ 2022-05-19 17:03 黑VS白-清墨 阅读(18) 评论(0) 推荐(0)
摘要: 题目链接:https://leetcode.cn/problems/minimum-moves-to-equal-array-elements-ii/ 个人题解:贪心。先排序找到中间值,然后求所有点到中心点的距离之和 代码: class Solution { public: int minMoves 阅读全文
posted @ 2022-05-19 16:58 黑VS白-清墨 阅读(19) 评论(0) 推荐(0)