摘要:
本博客不定期更新 LeetCode 题目总结,所有题目使用 Java 实现,小部分题目也提供 JavaScript 代码。我不追求一行 AC 但是我追求一题多解,比较常规的思路,解释清楚复杂度,代码可读性强。欢迎留言和评论,共同进步。这本是我自己用来复习的笔记,如果也能帮到你,那也是我的福报。 如果 阅读全文
摘要:
You are given an array nums consisting of positive integers. Starting with score = 0, apply the following algorithm: Choose the smallest integer of th 阅读全文
摘要:
Given a string s, return the maximum number of occurrences of any substring under the following rules: The number of unique characters in the substrin 阅读全文
摘要:
You are given a 2D integer array points, where points[i] = [xi, yi]. You are also given an integer w. Your task is to cover all the given points with 阅读全文
摘要:
Given an array of integers arr, return the number of subarrays with an odd sum. Since the answer can be very large, return it modulo 109 + 7. Example 阅读全文
摘要:
An array is considered special if every pair of its adjacent elements contains two numbers with different parity. You are given an array of integer nu 阅读全文
摘要:
You are given a 0-indexed m x n matrix grid consisting of positive integers. You can start at any cell in the first column of the matrix, and traverse 阅读全文
摘要:
You are given two 0-indexed strings str1 and str2. In an operation, you select a set of indices in str1, and for each index i in the set, increment st 阅读全文
摘要:
There is a circle of red and blue tiles. You are given an array of integers colors. The color of tile i is represented by colors[i]: colors[i] == 0 me 阅读全文
摘要:
You are given an m x n matrix of characters box representing a side-view of a box. Each cell of the box is one of the following: A stone '#' A station 阅读全文
摘要:
You are given an integer n representing the number of players in a game and a 2D array pick where pick[i] = [xi, yi] represents that the player x pick 阅读全文
摘要:
You are given two integers m and n representing a 0-indexed m x n grid. You are also given two 2D integer arrays guards and walls where guards[i] = [r 阅读全文
摘要:
You are given a string s consisting of the characters 'a', 'b', and 'c' and a non-negative integer k. Each minute, you may take either the leftmost ch 阅读全文
摘要:
You have a bomb to defuse, and your time is running out! Your informer will provide you with a circular array code of length of n and a key k. To decr 阅读全文
摘要:
An image smoother is a filter of the size 3 x 3 that can be applied to each cell of an image by rounding down the average of the cell and the eight su 阅读全文
摘要:
You are given two integer arrays persons and times. In an election, the ith vote was cast for persons[i] at time times[i]. For each query at a time t, 阅读全文
摘要:
Design a data structure to find the frequency of a given value in a given subarray. The frequency of a value in a subarray is the number of occurrence 阅读全文
摘要:
You are given an m x n binary matrix grid. A row or column is considered palindromic if its values read the same forward and backward. You can flip an 阅读全文
摘要:
You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexe 阅读全文
摘要:
Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays. The distance value is defined as the numb 阅读全文
摘要:
You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively. You are also given a 0 阅读全文