08 2024 档案

摘要: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) 编辑
摘要:LeetCode 552 学生出勤记录II 方法1:动态规划 class Solution { static int MOD = 1_000_000_007; static int MX = 1_000_01; static int[][][] dp = new int[MX][2][3]; sta 阅读全文
posted @ 2024-08-22 13:15 Koonan-Edogawa 阅读(5) 评论(0) 推荐(0) 编辑
摘要:LeetCode 3151 特殊数组I 方法1:遍历 class Solution { public boolean isArraySpecial(int[] nums) { for(int i = 1; i < nums.length; i++) { if(nums[i] % 2 == nums[ 阅读全文
posted @ 2024-08-13 10:20 Koonan-Edogawa 阅读(5) 评论(0) 推荐(0) 编辑
摘要:LeetCode 1035 不相交的线 方法1:动态规划 class Solution { public int maxUncrossedLines(int[] nums1, int[] nums2) { int n = nums1.length, m = nums2.length; int[][] 阅读全文
posted @ 2024-08-11 10:24 Koonan-Edogawa 阅读(7) 评论(0) 推荐(0) 编辑
摘要:LeetCode 2940 找到Alice和Bob可以相遇的建筑 方法1:线段树 class Solution { static int[] tree; // 存储区间的最大值 static void build(int o, int left, int right, int[] datas) { 阅读全文
posted @ 2024-08-10 11:43 Koonan-Edogawa 阅读(2) 评论(0) 推荐(0) 编辑
摘要:LeetCode 3131 找出与数组相加的整数I 方法1:枚举 class Solution { public int addedInteger(int[] nums1, int[] nums2) { return Arrays.stream(nums2).min().getAsInt() - A 阅读全文
posted @ 2024-08-08 14:14 Koonan-Edogawa 阅读(3) 评论(0) 推荐(0) 编辑
摘要:LeetCode 3130 找出所有稳定的二进制数组II 方法1:动态规划 class Solution { public int numberOfStableArrays(int zero, int one, int limit) { int MOD = 1_000_000_007; int[][ 阅读全文
posted @ 2024-08-07 09:39 Koonan-Edogawa 阅读(5) 评论(0) 推荐(0) 编辑
摘要:LeetCode 3129 找出所有稳定的二进制数组I 方法1:动态规划 第一步:定义 DP 数组 dp0[i][j]:填入 i0j1,并且最后填 0 的方案数 dp1[i][j]:填入 i0 和 \ 阅读全文
posted @ 2024-08-06 15:23 Koonan-Edogawa 阅读(13) 评论(0) 推荐(0) 编辑
摘要:LeetCode 572 另一棵树的子树 方法1:DFS + 暴力匹配 class Solution { public boolean isSubtree(TreeNode root, TreeNode subRoot) { if(root == null) return false; return 阅读全文
posted @ 2024-08-04 11:05 Koonan-Edogawa 阅读(4) 评论(0) 推荐(0) 编辑
摘要:数组简介 1. LeetCode 1991 找到数组的中间位置 方法1:前缀和 class Solution { public int findMiddleIndex(int[] nums) { int tol = 0, s = 0; for(int num : nums) tol += num; 阅读全文
posted @ 2024-08-03 18:31 Koonan-Edogawa 阅读(8) 评论(0) 推荐(0) 编辑
摘要:LeetCode 3143 正方形中的最多点数 方法1:维护次最小值 class Solution: def maxPointsInsideSquare(self, points: List[List[int]], s: str) -> int: Min1 = [inf] * 26; Min2 = 阅读全文
posted @ 2024-08-03 09:45 Koonan-Edogawa 阅读(7) 评论(0) 推荐(0) 编辑
摘要:LeetCode 3128 直角三角形 方法1:枚举 class Solution: def numberOfRightTriangles(self, grid: List[List[int]]) -> int: n = len(grid); m = len(grid[0]); dot = list 阅读全文
posted @ 2024-08-02 10:34 Koonan-Edogawa 阅读(4) 评论(0) 推荐(0) 编辑
摘要:LeetCode LCP.40 心算挑战 方法1:动态规划 class Solution: def maxmiumScore(self, cards: List[int], cnt: int) -> int: n = len(cards); old, now = 1, 0 # dp1[i][j] 前 阅读全文
posted @ 2024-08-02 10:15 Koonan-Edogawa 阅读(6) 评论(0) 推荐(0) 编辑
摘要:2.1 初级 (1)尺取法 ⭐ 反向扫描(左右指针) hdu 2029 Palindromes_easy version import java.util.Scanner; public class Main { public static void main(String[] args) { Sc 阅读全文
posted @ 2024-08-01 17:06 Koonan-Edogawa 阅读(5) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示