摘要: 点击查看代码 #include<iostream> using namespace std; const int N = 1e5 + 10; int a[N]; int quick_select(int l, int r, int k) { if (l >= r) return a[l]; int 阅读全文
posted @ 2022-04-23 23:16 wKingYu 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 #include <iostream> #include <algorithm> using namespace std; const int N = 1e5 + 10; struct Data { int x; double y; string z; bool operator< ( 阅读全文
posted @ 2022-04-23 22:59 wKingYu 阅读(30) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 class Solution { public: int NumberOf1(int n) { unsigned un = n; int res = 0; while (un) { res += un & 1; un >>= 1; } return res; } }; 首先将 n 转化 阅读全文
posted @ 2022-04-23 22:46 wKingYu 阅读(26) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 class Solution { public: vector<vector<int>> res; vector<vector<int>> permutation(vector<int>& nums) { sort(nums.begin(), nums.end()); do { res 阅读全文
posted @ 2022-04-23 22:42 wKingYu 阅读(18) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 class Solution { public: vector<int> findNumbersWithSum(vector<int>& nums, int target) { unordered_set<int> hash; for (int i = 0; i < nums.size 阅读全文
posted @ 2022-04-23 22:34 wKingYu 阅读(20) 评论(0) 推荐(0) 编辑
摘要: 堆排序 点击查看代码 class Solution { public: vector<int> getLeastNumbers_Solution(vector<int> input, int k) { priority_queue<int> heap; for (auto x : input) { 阅读全文
posted @ 2022-04-23 17:54 wKingYu 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {} * }; */ cla 阅读全文
posted @ 2022-04-23 17:44 wKingYu 阅读(14) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 class Solution { public: void reOrderArray(vector<int> &array) { int i = 0, j = array.size() - 1; while (i < j) { while (i <= j && array[i] % 2 阅读全文
posted @ 2022-04-23 17:41 wKingYu 阅读(24) 评论(0) 推荐(0) 编辑
摘要: 点击查看代码 class Solution { public: int getMissingNumber(vector<int>& nums) { if (nums.empty()) return 0; int l = 0, r = nums.size(); while (l < r) { int 阅读全文
posted @ 2022-04-23 13:00 wKingYu 阅读(18) 评论(0) 推荐(1) 编辑
摘要: ![image](https://img2022.cnblogs.com/blog/2674359/202204/2674359-20220422225030033-1871223327.png) 阅读全文
posted @ 2022-04-22 22:51 wKingYu 阅读(19) 评论(0) 推荐(1) 编辑