摘要: LeetCode 3127 构造相同颜色的正方形 方法1:模拟 class Solution { public boolean canMakeSquare(char[][] grid) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j+ 阅读全文
posted @ 2024-08-31 09:41 Koonan-Edogawa 阅读(4) 评论(0) 推荐(0) 编辑
摘要: LeetCode 3153 所有数对中数位差之和 方法1:模拟 class Solution { public long sumDigitDifferences(int[] nums) { int n = nums.length; long ans = 0; while (nums[0] > 0) 阅读全文
posted @ 2024-08-30 22:48 Koonan-Edogawa 阅读(3) 评论(0) 推荐(0) 编辑
摘要: LeetCode 3142 判断矩阵是否满足条件 方法1:模拟 class Solution { public boolean satisfiesConditions(int[][] grid) { int n = grid.length, m = grid[0].length; for (int 阅读全文
posted @ 2024-08-30 22:46 Koonan-Edogawa 阅读(4) 评论(0) 推荐(0) 编辑
摘要: LeetCode 3134 找出唯一性数组的中位数 方法1:二分 + 滑动窗口 + 哈希表 class Solution { public int medianOfUniquenessArray(int[] nums) { int n = nums.length; // 左中位数下标 下标从 1 开 阅读全文
posted @ 2024-08-27 13:05 Koonan-Edogawa 阅读(8) 评论(0) 推荐(0) 编辑
摘要: LeetCode 690 员工的重要性 方法1:DFS + 哈希表 /* // Definition for Employee. class Employee { public int id; public int importance; public List<Integer> subordina 阅读全文
posted @ 2024-08-26 12:12 Koonan-Edogawa 阅读(4) 评论(0) 推荐(0) 编辑
摘要: LeetCode 3146 两个字符串的排列差 方法1:模拟 + 标记数组(哈希表) class Solution { public int findPermutationDifference(String s, String t) { int[] idx = new int[26]; int n 阅读全文
posted @ 2024-08-24 09:58 Koonan-Edogawa 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 1. LeetCode 3 无重复字符的最长子串 方法1:滑动窗口 + 哈希 class Solution { public int lengthOfLongestSubstring(String s) { HashSet<Character> set = new HashSet<Character 阅读全文
posted @ 2024-08-23 17:51 Koonan-Edogawa 阅读(22) 评论(0) 推荐(0) 编辑
摘要: 1. LeetCode 1456 定长子串中元音的最大数目 方法1:滑动窗口 class Solution { public int maxVowels(String s, int k) { int n = s.length(), count = 0, ans = 0; for (int i = 0 阅读全文
posted @ 2024-08-22 15:48 Koonan-Edogawa 阅读(16) 评论(0) 推荐(0) 编辑
摘要: LeetCode 3133 数组最后一个元素的最小值 方法1:位运算 class Solution { public long minEnd(int n, int x) { int idx = 0; // 用于记录 x 二进制为 0 的下标 n--; // 第一个数就是 x long ans = x 阅读全文
posted @ 2024-08-22 13:19 Koonan-Edogawa 阅读(5) 评论(0) 推荐(0) 编辑
摘要: LeetCode 3154 到达第K级台阶的方案数 方法1:数学 class Solution { static int MX = 31; static int[][] res = new int[31][31]; static { // 使用计算需要开 long for (int i = 0; i 阅读全文
posted @ 2024-08-22 13:17 Koonan-Edogawa 阅读(4) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示