随笔分类 - 算法散题
摘要:1. LeetCode 3 无重复字符的最长子串 方法1:滑动窗口 + 哈希 class Solution { public int lengthOfLongestSubstring(String s) { HashSet<Character> set = new HashSet<Character
阅读全文
摘要: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
阅读全文
摘要:数组简介 1. LeetCode 1991 找到数组的中间位置 方法1:前缀和 class Solution { public int findMiddleIndex(int[] nums) { int tol = 0, s = 0; for(int num : nums) tol += num;
阅读全文
摘要:牛客 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
阅读全文