CNoodle
  • Home
  • Archives
  • Tags
  • About

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] 2874. Maximum Value of an Ordered Triplet II

You are given a 0-indexed integer array nums. Return the maximum value over all triplets of indices (i, j, k) such that i < j < k. If all such triplets have a negative value, return 0. The value
2025-04-01
#leetcode #java #array #hashmap #two sum

[LeetCode] 2780. Minimum Index of a Valid Split

An element x of an integer array arr of length m is dominant if more than half the elements of arr have a value of x. You are given a 0-indexed integer array nums of length n with one dominant element
2025-03-27
#leetcode #java #array #hashmap

[LeetCode] 2033. Minimum Operations to Make a Uni-Value Grid

You are given a 2D integer grid of size m x n and an integer x. In one operation, you can add x to or subtract x from any element in the grid. A uni-value grid is a grid where all the elements of it a
2025-03-26
#leetcode #java #array #sort #math #matrix

[LeetCode] 2712. Minimum Cost to Make All Characters Equal

You are given a 0-indexed binary string s of length n on which you can apply two types of operations: Choose an index i and invert all characters from index 0 to index i (both inclusive), with a cost
2025-03-26
#leetcode #java #dynamic programming #greedy #string

[LeetCode] 3191. Minimum Operations to Make Binary Array Elements Equal to One I

You are given a binary array nums. You can do the following operation on the array any number of times (possibly zero): Choose any 3 consecutive elements from the array and flip all of them.Flipping a
2025-03-19
#leetcode #java #array #greedy #bit manipulation

[LeetCode] 2610. Convert an Array Into a 2D Array With Conditions

You are given an integer array nums. You need to create a 2D array from nums satisfying the following conditions: The 2D array should contain only the elements of the array nums.Each row in the 2D arr
2025-03-18
#leetcode #java #array #hashmap

[LeetCode] 2401. Longest Nice Subarray

You are given an array nums consisting of positive integers. We call a subarray of nums nice if the bitwise AND of every pair of elements that are in different positions in the subarray is equal to 0.
2025-03-18
#leetcode #java #array #sliding window #bit manipulation
123…41

Search

Hexo Fluid