随笔分类 -  算法散题

摘要: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) 编辑
摘要:数组简介 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) 编辑
摘要:牛客 23486 小A与小B 方法1:BFS from collections import deque from typing import List def bfs(pos: tuple, direction: int) -> List[List[int]]: ans = [[MAX] * M 阅读全文
posted @ 2024-07-29 22:00 Koonan-Edogawa 阅读(7) 评论(0) 推荐(0) 编辑

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