摘要: 一、题目 二、分析代码 我的想法其实很直观,就是先求一下绝对值,然后排序,然后求平方 class Solution { public: vector<int> sortedSquares(vector<int>& nums) { for( auto& i : nums){ if(i < 0){ i 阅读全文
posted @ 2021-11-03 15:46 星光夜 阅读(45) 评论(0) 推荐(0)
摘要: 一、题目 题目链接: https://leetcode-cn.com/problems/remove-element/ 二、分析与代码 这个其实跟之前的题目,查找重复元素,很类似,我就想着逐个遍历就好了,不符合要求的放到最后,最后的那个放到最前面。 class Solution { public: 阅读全文
posted @ 2021-11-03 15:29 星光夜 阅读(32) 评论(0) 推荐(0)