上一页 1 2 3 4 5 6 7 ··· 15 下一页
摘要: 分析: 方法一:贪心,首先将每个数的位置用map保存,遍历偶数索引的数,异或1找到它的情侣,如果不在当前索引i+1的位置上,就用map找到这个数,交换到i+1的位置上,并且更新i+1位置上的数在map中的位置 class Solution { public int minSwapsCouples(i 阅读全文
posted @ 2020-08-27 15:30 Sexyomaru 阅读(135) 评论(0) 推荐(0) 编辑
摘要: class Solution { LinkedList<String> res = new LinkedList<>(); Map<String,PriorityQueue<String>> map = new HashMap<>(); public List<String> findItinera 阅读全文
posted @ 2020-08-27 10:13 Sexyomaru 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 分析:先按照w+s排序,从前到后遍历即可 #include <bits/stdc++.h> using namespace std; const int N = 50050; typedef pair<int,int> PII; PII f[N]; int n; int main() { scanf 阅读全文
posted @ 2020-08-26 22:00 Sexyomaru 阅读(152) 评论(0) 推荐(0) 编辑
摘要: 分析:先按区间左端点进行排序,然后遍历区间,找一个区间左右端点覆盖起始点,右端点尽量远,直到可以覆盖目标区间右端点 #include <bits/stdc++.h> using namespace std; const int N = 100010; struct Edge{int a, b;} e 阅读全文
posted @ 2020-08-26 15:23 Sexyomaru 阅读(118) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean judgePoint24(int[] nums) { double[] a = new double[]{nums[0],nums[1],nums[2],nums[3]}; return find(a); } public boolea 阅读全文
posted @ 2020-08-26 15:05 Sexyomaru 阅读(82) 评论(0) 推荐(0) 编辑
摘要: 分析:先将区间按左端点排序,然后建一个小堆存放以有组的右端点,然后遍历区间,当堆为空或堆中最小的右端点都大于当前区间的左端点, 则当前区间另分一组,否则就将当前区间划分给堆中最小左端点的那个区间,并更新这个区间的右端点,最后返回堆的大小 #include <bits/stdc++.h> using 阅读全文
posted @ 2020-08-26 11:09 Sexyomaru 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 分析:先按区间的右端点排序,然后从左到右遍历,当前区间左端点小于上一区间的右端点,总个数不变,否则总个数加一,并更新右端点 #include <bits/stdc++.h> using namespace std; const int N = 100010; struct Edge{int a, b 阅读全文
posted @ 2020-08-26 10:26 Sexyomaru 阅读(77) 评论(0) 推荐(0) 编辑
摘要: class Solution { List<Integer> temp = new ArrayList<Integer>(); List<List<Integer>> ans = new ArrayList<List<Integer>>(); public List<List<Integer>> f 阅读全文
posted @ 2020-08-25 19:47 Sexyomaru 阅读(87) 评论(0) 推荐(0) 编辑
摘要: 分析:十叉树的遍历 class Solution { public List<Integer> lexicalOrder(int n) { List<Integer> res = new ArrayList<>(); for(int i = 1; i < 10; i++) { dfs(n,res,i 阅读全文
posted @ 2020-08-25 15:06 Sexyomaru 阅读(119) 评论(0) 推荐(0) 编辑
摘要: 分析: class Solution { public int subarrayBitwiseORs(int[] A) { Set<Integer> set = new HashSet<>(); Set<Integer> cur = new HashSet<>(); for(int num : A) 阅读全文
posted @ 2020-08-20 15:47 Sexyomaru 阅读(124) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 15 下一页