LeetCode 题目总结 本博客不定期更新 LeetCode 题目总结,所有题目使用 Java 实现,小部分题目也提供 JavaScript 代码。我不追求一行 AC 但是我追求一题多解,比较常规的思路,解释清楚复杂度,代码可读性强。欢迎留言和评论,共同进步。这本是我自己用来复习的笔记,如果也能帮到你,那也是我的福报。 如果你想按类型刷题,可以参考我的标签。我做出的分类比 LC 官方的更细一些,比如我有如下展示的这些类型, 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] 1518. Water Bottles There are numBottles water bottles that are initially full of water. You can exchange numExchange empty water bottles from the market with one full water bottle. The operation of drinking a full water 2025-09-30 #leetcode #java #math #simulation
[LeetCode] 3484. Design Spreadsheet A spreadsheet is a grid with 26 columns (labeled from ‘A’ to ‘Z’) and a given number of rows. Each cell in the spreadsheet can hold an integer value between 0 and 105. Implement the Spreadsheet class: 2025-09-19 #leetcode #hashmap #java #string #design
[LeetCode] 3408. Design Task Manager There is a task management system that allows users to manage their tasks, each associated with a priority. The system should efficiently handle adding, modifying, executing, and removing tasks. Imple 2025-09-18 #leetcode #hashmap #java #design #heap
[LeetCode] 1935. Maximum Number of Words You Can Type There is a malfunctioning keyboard where some letter keys do not work. All other keys on the keyboard work properly. Given a string text of words separated by a single space (no leading or trailing sp 2025-09-14 #leetcode #hashmap #java #string
[LeetCode] 1504. Count Submatrices With All Ones Given an m x n binary matrix mat, return the number of submatrices that have all ones. Example 1:Input: mat = [[1,0,1],[1,1,0],[1,1,0]]Output: 13Explanation:There are 6 rectangles of side 1x1.The 2025-08-21 #leetcode #array #java #stack #monotonic stack
[LeetCode] 2044. Count Number of Maximum Bitwise-OR Subsets Given an integer array nums, find the maximum possible bitwise OR of a subset of nums and return the number of different non-empty subsets with the maximum bitwise OR. An array a is a subset of an arr 2025-07-27 #leetcode #array #java #dfs #backtracking #bit manipulation
[LeetCode] 2210. Count Hills and Valleys in an Array You are given a 0-indexed integer array nums. An index i is part of a hill in nums if the closest non-equal neighbors of i are smaller than nums[i]. Similarly, an index i is part of a valley in nums i 2025-07-26 #leetcode #array #java