上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页
摘要: 方法一:Map加双向链表 class LRUCache { class Node { public int key, val; Node pre,next; public Node() {} public Node(int k, int v) { key = k; val = v; } } priv 阅读全文
posted @ 2020-07-23 21:13 Sexyomaru 阅读(107) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-07-22 19:49 Sexyomaru 阅读(134) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int maxEvents(int[][] events) { Arrays.sort(events, Comparator.comparingInt(o -> o[0])); PriorityQueue<Integer> queue = new Pr 阅读全文
posted @ 2020-07-22 15:54 Sexyomaru 阅读(140) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int findTheLongestSubstring(String s) { int n = s.length(); int[] pos = new int[32]; // 11111最大为31,记录所有状态可能的情况开32就可以了 // pos[s 阅读全文
posted @ 2020-07-22 13:45 Sexyomaru 阅读(173) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int countCornerRectangles(int[][] grid) { if(grid.length < 2 || grid[0].length < 2) return 0; int m = grid.length, n = grid[0] 阅读全文
posted @ 2020-07-21 16:37 Sexyomaru 阅读(133) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int numSubmat(int[][] mat) { if(mat.length == 0 || mat[0].length == 0) return 0; int m = mat.length, n = mat[0].length; int[][ 阅读全文
posted @ 2020-07-21 16:36 Sexyomaru 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 分析:dp[i][j]表示右下角坐标为(i,j)的最大正方形边长,累加即可 class Solution { public int countSquares(int[][] matrix) { if(matrix.length == 0 || matrix[0].length == 0) retur 阅读全文
posted @ 2020-07-21 16:33 Sexyomaru 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 位运算性质:a&b不会大于a也不会大于b,会将二进制中的1变为0,但是0不会变为1 a|b不会小于a也不会小于b,会将二进制中的0变为1,但是1不会变为0 class Solution { public int closestToTarget(int[] arr, int target) { Set 阅读全文
posted @ 2020-07-21 15:48 Sexyomaru 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 参考https://space.bilibili.com/3203291/零神的题解 class Solution { public: int closestToTarget(vector<int>& arr, int target) { int ans = abs(arr[0] - target) 阅读全文
posted @ 2020-07-20 11:01 Sexyomaru 阅读(157) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <cstring> #include <cmath> using namespace std; const int N = 200010, M = 18; int n,m; int w[N],f[N][M]; void init() { fo 阅读全文
posted @ 2020-07-20 10:56 Sexyomaru 阅读(147) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页