标签: leetcode

22 篇文章

LeetCode hot100@双指针
双指针法:通过两个指针在一个for循环下完成两个for循环的工作,一般是将O(n^2)的时间复杂度,降为O(n) 283. 移动零✅ 简单模拟 不改变数组内元素的相对位置 复杂度O(n) class Solution { public: void moveZeroes(vector<int>& nums) { int slow …
LeetCode hot100@哈希
1. 两数之和✅ 错过一次没关系,第二次把握住就好 class Solution { public: vector<int> twoSum(vector<int>& nums, int target) { unordered_map<int, int> mp; vector<int> res;…