LeetCode 题目总结 本博客不定期更新 LeetCode 题目总结,所有题目使用 Java 实现,前 400 题的部分题目也提供 JavaScript 代码。但是我想现如今你完全可以用任何 AI 工具把 Java 代码翻译成 JavaScript 或任何其他语言以达到学习的目的。我不追求一行 AC 但是我追求一题多解,比较常规的思路,解释清楚复杂度,代码可读性强。欢迎留言和评论,共同进步。这本是我自己用来复习的笔记,如 2020-03-18 #leetcode
[LeetCode] 二分查找模板 binary search 二分法是算法题里面一个比较基础但是很容易错的概念,一开始练习的时候由于不熟悉二分法的套路,反复出现死循环或者目标值找错,非常影响做题心情。我总结了如下几个模板。原则上这里的模板无论你使用哪一个,都可以解决二分法类型的问题,只不过有一些题目,比如寻找一个最大值/最小值的,可能某一个模板更适合,需要判断的条件较少。 如下模板是用Java实现的 模板一,找有序数组中是否存在一个目标值。注意 r 2021-01-12 #leetcode #java #binary search
给网站添加免费的SSL证书 自己曾经做了一个网站部署在一台 ubuntu 服务器上,但是由于一开始不会配置 SSL,所以花钱买了付费的 SSL。最近发现了 Let’s Encrypt,可以免费申请 SSL 证书,下面是详细的教程。 我的网站是一个 React 的项目,所以我的服务器上只是一个简单的 Node.js 环境 + Nginx。我主要参考了这个帖子。如果你是用其他的环境比如LAMP那一套的,请自行搜索其他的教程。 0 2024-11-02 #devops
[LeetCode] 815. Bus Routes You are given an array routes representing bus routes where routes[i] is a bus route that the ith bus repeats forever. For example, if routes[0] = [1, 5, 7], this means that the 0th bus travels i 2025-07-21 #leetcode #array #hashmap #java #bfs #graph
[LeetCode] 2058. Find the Minimum and Maximum Number of Nodes Between Critical Points A critical point in a linked list is defined as either a local maxima or a local minima. A node is a local maxima if the current node has a value strictly greater than the previous node and the next n 2025-07-20 #leetcode #java #linked list
[LeetCode] 3201. Find the Maximum Length of Valid Subsequence I You are given an integer array nums.A subsequence sub of nums with length x is called valid if it satisfies: (sub[0] + sub[1]) % 2 == (sub[1] + sub[2]) % 2 == … == (sub[x 2025-07-15 #leetcode #array #java #greedy
[LeetCode] 3136. Valid Word A word is considered valid if: It contains a minimum of 3 characters.It contains only digits (0-9), and English letters (uppercase and lowercase).It includes at least one vowel.It includes at least on 2025-07-14 #leetcode #java #string
[LeetCode] 2410. Maximum Matching of Players With Trainers You are given a 0-indexed integer array players, where players[i] represents the ability of the ith player. You are also given a 0-indexed integer array trainers, where trainers[j] represents the trai 2025-07-13 #leetcode #two pointer #java #greedy #sort
[LeetCode] 3330. Find the Original Typed String I Alice is attempting to type a specific string on her computer. However, she tends to be clumsy and may press a key for too long, resulting in a character being typed multiple times. Although Alice tri 2025-06-30 #leetcode #java #string
[LeetCode] 2200. Find All K-Distant Indices in an Array You are given a 0-indexed integer array nums and two integers key and k. A k-distant index is an index i of nums for which there exists at least one index j such that |i - j| <= k and nums[j] 2025-06-23 #leetcode #array #two pointer #java