摘要:
1779. 找到最近的有相同 X 或 Y 坐标的点 class Solution { public int nearestValidPoint(int x, int y, int[][] points) { int n = points.length; int res = (int)0x3f3f3f 阅读全文
摘要:
1758. 生成交替二进制字符串的最少操作数 class Solution { public int minOperations(String s) { char[] c = s.toCharArray(); int n = c.length; int res1 = 0; int res2 = 0; 阅读全文
摘要:
1752. 检查数组是否经排序和轮转得到 class Solution { public boolean check(int[] nums) { int n = nums.length; int x = 0; for(int i = 0 ; i < n - 1 ; i ++ ){ if(nums[i 阅读全文
摘要:
882. 细分图中的可到达节点 class Solution { int N = 3010, M = 20010, INF = 0x3f3f3f3f; int[] h = new int[N]; int[] e = new int[M]; int[] w = new int[M]; int[] ne 阅读全文
摘要:
809. 情感丰富的文字 class Solution { public int expressiveWords(String s, String[] words) { int res = 0; // 空字符串 if (s.isEmpty()) { // 找words中有多少个空字符串 for (S 阅读全文
摘要:
795. 区间子数组个数 题解: 实现一个函数cal 返回小于等于k的子数组数量 函数cal,可以用双指针实现 class Solution { public int numSubarrayBoundedMax(int[] nums, int left, int right) { return (i 阅读全文
摘要:
1742. 盒子中小球的最大数量 class Solution { public int countBalls(int l, int r) { int[] box = new int[50]; int max = 0; for (int i = l; i <= r; i++) { int num = 阅读全文