随笔分类 - LeetCode
摘要:打地鼠 欢迎各位勇者来到力扣城,本次试炼主题为「打地鼠」。 勇者面前有一个大小为 3*3 的打地鼠游戏机,地鼠将随机出现在各个位置,moles[i] = [t,x,y] 表示在第 t 秒会有地鼠出现在 (x,y) 位置上,并于第 t+1 秒该地鼠消失。 勇者有一把可敲打地鼠的锤子,初始时刻(即第 0
阅读全文
摘要:Count Subarrays With Median K You are given an array nums of size consisting of distinct integers from to and a positive integer . Retu
阅读全文
摘要:Number of Beautiful Partitions You are given a string s that consists of the digits '1' to '9' and two integers k and minLength. A partition of s is c
阅读全文
摘要:Maximum Number of Non-overlapping Palindrome Substrings You are given a string s and a positive integer k . Select a set of non-overlapping substrings
阅读全文
摘要:Minimum Number of Operations to Sort a Binary Tree by Level You are given the root of a binary tree with unique values. In one operation, you can choo
阅读全文
摘要:Next Greater Element IV You are given a 0-indexed array of non-negative integers nums . For each integer in nums , you must find its respective second
阅读全文
摘要:Count Subarrays With Fixed Bounds You are given an integer array nums and two integers minK and maxK . A fixed-bound subarray of nums is a subarray th
阅读全文
摘要:Minimize Maximum of Array You are given a 0-indexed array nums comprising of non-negative integers. In one operation, you must: Choose an integer
阅读全文
摘要:Minimum Swaps To Make Sequences Increasing You are given two integer arrays of the same length nums1 and nums2 . In one operation, you are allowed to
阅读全文
摘要:Using a Robot to Print the Lexicographically Smallest String You are given a string s and a robot that currently holds an empty string t . Apply one o
阅读全文
摘要:Maximum Deletions on a String You are given a string s consisting of only lowercase English letters. In one operation, you can: Delete the entire stri
阅读全文
摘要:单调栈的定义与证明 前言 最近领悟到了单调栈的本质,特此来记录一下我的理解。 单调栈主要用来解决这样一类问题,当枚举到下标,要求在下标之前小于大于的数的下标中,找到最小最大的下标位置。 一共有四种不同的情况,下面来证明在这四种情况中,栈内维护的元素始终单调递增或单调
阅读全文
摘要:Find All Good Indices You are given a 0-indexed integer array nums of size and a positive integer . We call an index in the range $k \leq i
阅读全文
摘要:Longest Subarray With Maximum Bitwise AND You are given an integer array nums of size . Consider a non-empty subarray from nums that has the maximu
阅读全文
摘要:Sum of Prefix Scores of Strings You are given an array words of sizeco sisting of non-empty strings. We define the score of a string word as the n
阅读全文
摘要:Minimum Money Required Before Transactions You are given a 0-indexed 2D integer array transactions , where transactions[i] = [costi, cashbacki] . The
阅读全文
摘要:Smallest Subarrays With Maximum Bitwise OR You are given a 0-indexed array nums of length , consisting of non-negative integers. For each index
阅读全文
摘要:最长上升子序列 给定一个长度为 的数列,求数值严格单调递增的子序列的长度最长是多少。 输入格式 第一行包含整数 。 第二行包含 个整数,表示完整序列。 输出格式 输出一个整数,表示最大长度。 数据范围 ,${−10}^{9} \leq \
阅读全文
摘要:Evaluate Division You are given an array of variable pairs equations and an array of real numbers values , where equations[i] = [Ai, Bi] and values[i]
阅读全文
摘要:Count Unique Characters of All Substrings of a Given String Let's define a function countUniqueChars(s) that returns the number of unique characters o
阅读全文