上一页 1 2 3 4 5 6 7 8 ··· 15 下一页
摘要: class Solution { public int getLengthOfOptimalCompression(String s, int k) { int n = s.length(); int[][] dp = new int[n+1][k+1]; // dp[i][j]:考虑前i个字符最多 阅读全文
posted @ 2020-08-20 15:41 Sexyomaru 阅读(355) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int findNumberOfLIS(int[] nums) { int n = nums.length; int[] dp = new int[n]; Arrays.fill(dp,1); // dp[i] 以i结尾的最大长度 int[] coun 阅读全文
posted @ 2020-08-19 19:09 Sexyomaru 阅读(81) 评论(0) 推荐(0) 编辑
摘要: class Solution { public List<Integer> largestDivisibleSubset(int[] nums) { List<Integer> res = new ArrayList<>(); int n = nums.length; if(n == 0) retu 阅读全文
posted @ 2020-08-19 17:10 Sexyomaru 阅读(113) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; const int N = 6060; int h[N], e[N], ne[N],idx; int w[N], f[N][2]; bool hasF[N]; int n; void add(int a, i 阅读全文
posted @ 2020-08-18 20:48 Sexyomaru 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 方法一: 背包模型 #include <bits/stdc++.h> using namespace std; const int N = 10010, mod = 1e9 + 7; int dp[N][N]; int n; int main() { scanf("%d",&n); for(int 阅读全文
posted @ 2020-08-18 20:00 Sexyomaru 阅读(164) 评论(0) 推荐(0) 编辑
摘要: class Solution { int[] color; Map<Integer,List<Integer>> map; public boolean possibleBipartition(int N, int[][] dislikes) { map = new HashMap<>(); col 阅读全文
posted @ 2020-08-18 16:22 Sexyomaru 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 方法一:记录0的个数减1的个数有没有出现过 class Solution { public int findMaxLength(int[] nums) { int n = nums.length; Map<Integer,Integer> map = new HashMap<>(); map.put 阅读全文
posted @ 2020-08-18 15:37 Sexyomaru 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 方法一:动态规划 分奇数和偶数的情况 class Solution { public int[] countBits(int num) { int[] dp = new int[num+1]; for(int i = 0; i <= num; i++) { if(i % 2 == 0) dp[i] 阅读全文
posted @ 2020-08-18 14:51 Sexyomaru 阅读(80) 评论(0) 推荐(0) 编辑
摘要: class Solution { Map<Integer, Integer> map = new HashMap(); public int minDays(int n) { if(n == 0) return 0; if(!map.containsKey(n)){ int ans = n; // 阅读全文
posted @ 2020-08-16 15:49 Sexyomaru 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 分析:在整个数域范围上二分查找最小磁力的大小 然后记录这个最小磁力可以在position上放置几个球,根据球的数量与m的大小来决定二分范围 class Solution { public int maxDistance(int[] position, int m) { int n = positio 阅读全文
posted @ 2020-08-16 14:46 Sexyomaru 阅读(251) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 15 下一页