LeetCode
文章平均质量分 68
杨鑫newlfe
算法就是我的灵魂
展开
-
LeetCode --- 2068. Check Whether Two Strings are Almost Equivalent 解题报告
Two strings and are considered almost equivalent if the differences between the frequencies of each letter from to between and is at most .Given two strings and , each of length , return if and are almost equivalent, or otherwise.The frequency o原创 2024-03-16 14:16:31 · 100 阅读 · 0 评论 -
LeetCode --- 2062. Count Vowel Substrings of a String 解题报告
A substring is a contiguous (non-empty) sequence of characters within a string.A vowel substring is a substring that only consists of vowels (, , , , and ) and has all five vowels present in it.Given a string , return the number of vowel substrings in .Exa原创 2024-03-14 08:08:23 · 94 阅读 · 0 评论 -
LeetCode --- 2057. Smallest Index With Equal Value 解题报告
Given a 0-indexed integer array , return the smallest index of such that , or if such index does not exist. denotes the remainder when is divided by .Example 1:Input: nums = [0,1,2]Output: 0Explanation: i=0: 0 mod 10 = 0 == nums[0].i=1: 1 mod 10 =原创 2024-03-14 07:48:04 · 151 阅读 · 0 评论 -
LeetCode --- 2053. Kth Distinct String in an Array 解题报告
A distinct string is a string that is present only once in an array.Given an array of strings , and an integer , return the distinct string present in . If there are fewer than distinct strings, return an empty string .Note that the strings are considere原创 2024-03-05 07:35:58 · 90 阅读 · 1 评论 -
LeetCode --- 2047. Number of Valid Words in a Sentence 解题报告
LeetCode --- 2047. Number of Valid Words in a Sentence 解题报告原创 2024-02-17 03:18:58 · 232 阅读 · 0 评论 -
LeetCode --- 2042. Check if Numbers Are Ascending in a Sentence 解题报告
A sentence is a list of tokens separated by a single space with no leading or trailing spaces. Every token is either a positive number consisting of digits with no leading zeros, or a word consisting of lowercase English letters.Given a string representi原创 2024-02-02 00:14:14 · 97 阅读 · 0 评论 -
LeetCode --- 2037. Minimum Number of Moves to Seat Everyone 解题报告
There are seats and students in a room. You are given an array of length , where is the position of the seat. You are also given the array of length , where is the position of the student.You may perform the following move any number of times:Retur原创 2024-02-01 23:58:54 · 227 阅读 · 0 评论 -
LeetCode --- 2032. Two Out of Three 解题报告
Given three integer arrays , , and , return a distinct array containing all the values that are present in at least two out of the three arrays. You may return the values in any order.Example 1:Input: nums1 = [1,1,3,2], nums2 = [2,3], nums3 = [3]Output:原创 2024-01-31 22:04:24 · 153 阅读 · 0 评论 -
LeetCode --- 2027. Minimum Moves to Convert String 解题报告
You are given a string consisting of characters which are either or .A move is defined as selecting three consecutive characters of and converting them to . Note that if a move is applied to the character , it will stay the same.Return the minimum numb原创 2024-01-31 21:45:47 · 134 阅读 · 0 评论 -
LeetCode --- CodeTestcaseTest ResultTest Result2022. Convert 1D Array Into 2D Array 解题报告
模拟操作,给定一个一位数组,利用规律使其变为二维数组。这里就通过盘点给定一位数组的长度是否等于m*n直接判断是否可变换。然后通过两个for遍历赋值即可原创 2024-01-19 01:58:54 · 36 阅读 · 0 评论 -
LeetCode --- 2016. Maximum Difference Between Increasing Elements 解题报告
LeetCode升序求差值原创 2024-01-15 01:56:58 · 113 阅读 · 0 评论 -
LeetCode --- 2011. Final Value of Variable After Performing Operations 解题报告
There is a programming language with only four operations and one variable :Initially, the value of is .Given an array of strings containing a list of operations, return the final value of after performing all the operations.Example 1:Input: operations原创 2023-12-10 23:55:52 · 142 阅读 · 0 评论 -
LeetCode --- 2006. Count Number of Pairs With Absolute Difference K 解题报告
Given an integer array and an integer , return the number of pairs where such that .The value of is defined as:Example 1:Input: nums = [1,2,2,1], k = 1Output: 4Explanation: The pairs with an absolute difference of 1 are:- [1,2,2,1]- [1,2,2,1]- [1原创 2023-12-10 23:44:34 · 129 阅读 · 0 评论 -
LeetCode --- 2000. Reverse Prefix of Word 解题报告
Given a 0-indexed string and a character , reverse the segment of that starts at index and ends at the index of the first occurrence of (inclusive). If the character does not exist in , do nothing.Return the resulting string.Example 1:Input: word = &原创 2023-12-03 12:20:01 · 207 阅读 · 0 评论 -
LeetCode --- 1995. Count Special Quadruplets 解题报告
两种解法处理移动下标算法问题原创 2023-11-11 11:22:36 · 161 阅读 · 0 评论 -
LeetCode --- CodeTestcaseTestcaseTest Result1991. Find the Middle Index in Array 解题报告
Given a 0-indexed integer array , find the leftmost (i.e., the smallest amongst all the possible ones).A is an index where .If , the left side sum is considered to be . Similarly, if , the right side sum is considered to be .Return the leftmost that sat原创 2023-11-05 23:27:30 · 92 阅读 · 0 评论 -
LeetCode --- 1984. Minimum Difference Between Highest and Lowest of K Scores 解题报告
You are given a 0-indexed integer array , where represents the score of the student. You are also given an integer .Pick the scores of any students from the array so that the difference between the highest and the lowest of the scores is minimized.Retu原创 2023-11-03 08:48:14 · 75 阅读 · 0 评论 -
LeetCode --- 1979. Find Greatest Common Divisor of Array 解题报告
Given an integer array , return the greatest common divisor of the smallest number and largest number in .The greatest common divisor of two numbers is the largest positive integer that evenly divides both numbers.Example 1:Input: nums = [2,5,6,9,10]Outp原创 2023-10-23 00:18:16 · 242 阅读 · 0 评论 -
LeetCode --- 1974. Minimum Time to Type Word Using Special Typewriter 解题报告
There is a special typewriter with lowercase English letters to arranged in a circle with a pointer. A character can only be typed if the pointer is pointing to that character. The pointer is initially pointing to the character .Each second, you may perf原创 2023-10-20 00:12:17 · 580 阅读 · 0 评论 -
LeetCode --- 1971. Find if Path Exists in Graph 解题报告
并查集处理无向图联通问题原创 2023-10-09 23:19:16 · 558 阅读 · 0 评论 -
LeetCode --- 1967. Number of Strings That Appear as Substrings in Word 解题报告
Given an array of strings and a string , return the number of strings in that exist as a substring in .A substring is a contiguous sequence of characters within a string.Example 1:Input: patterns = ["a","abc","bc","d&q原创 2023-09-25 01:06:53 · 470 阅读 · 0 评论 -
LeetCode --- 1961. Check If String Is a Prefix of Array 解题报告
Given a string and an array of strings , determine whether is a prefix string of .A string is a prefix string of if can be made by concatenating the first strings in for some positive no larger than .Return if is a prefix string of , or otherwis原创 2023-09-25 00:51:33 · 280 阅读 · 0 评论 -
LeetCode --- 1957. Delete Characters to Make Fancy String 解题报告
A fancy string is a string where no three consecutive characters are equal.Given a string , delete the minimum possible number of characters from to make it fancy.Return the final string after the deletion. It can be shown that the answer will always be u原创 2023-09-24 10:55:41 · 130 阅读 · 0 评论 -
LeetCode --- 1952. Three Divisors 解题报告
Given an integer , return if has exactly three positive divisors. Otherwise, return .An integer is a divisor of if there exists an integer such that .Example 1:Input: n = 2Output: falseExplantion: 2 has only two divisors: 1 and 2.Example 2:Inpu原创 2023-09-24 10:33:02 · 115 阅读 · 0 评论 -
LeetCode --- 222. Count Complete Tree Nodes 解题报告
Given the of a complete binary tree, return the number of the nodes in the tree.According to Wikipedia, every level, except possibly the last, is completely filled in a complete binary tree, and all nodes in the last level are as far left as possible. It原创 2023-09-23 20:10:58 · 203 阅读 · 0 评论 -
LeetCode --- 145. Binary Tree Postorder Traversal 解题报告
Given the of a binary tree, return the postorder traversal of its nodes' values.Example 1:Input: root = [1,null,2,3]Output: [3,2,1]Example 2:Input: root = []Output: []Example 3:Input: root = [1]Output: [1]Constraints:Follow up: Recursive so原创 2023-09-23 19:34:38 · 124 阅读 · 0 评论 -
LeetCode --- 1945. Sum of Digits of String After Convert 解题报告
You are given a string consisting of lowercase English letters, and an integer .First, convert into an integer by replacing each letter with its position in the alphabet (i.e., replace with , with , ..., with ). Then, transform the integer by replacin原创 2023-09-23 16:58:28 · 135 阅读 · 0 评论 -
LeetCode --- 1941. Check if All Characters Have Equal Number of Occurrences 解题报告
Given a string , return if is a good string, or otherwise.A string is good if all the characters that appear in have the same number of occurrences (i.e., the same frequency).Example 1:Input: s = "abacbc"Output: trueExplanation: The chara原创 2023-09-23 02:36:32 · 65 阅读 · 0 评论 -
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 of words separated by a single space (no leading or trailing spaces) and a string of all distinct letter keys that are brok原创 2023-09-10 10:58:05 · 549 阅读 · 0 评论 -
LeetCode --- 1929. Concatenation of Array 解题报告
Given an integer array of length , you want to create an array of length where and for (0-indexed).Specifically, is the concatenation of two arrays.Return the array .Example 1:Input: nums = [1,2,1]Output: [1,2,1,1,2,1]Explanation: The array ans原创 2023-09-10 10:39:15 · 315 阅读 · 0 评论 -
LeetCode --- 1925. Count Square Sum Triples 解题报告
A square triple is a triple where , , and are integers and .Given an integer , return the number of square triples such that .Example 1:Input: n = 5Output: 2Explanation: The square triples are (3,4,5) and (4,3,5).Example 2:Input: n = 10Output: 4原创 2023-09-05 01:59:00 · 285 阅读 · 0 评论 -
LeetCode --- 1920. Build Array from Permutation 解题报告
Given a zero-based permutation (0-indexed), build an array of the same length where for each and return it.A zero-based permutation is an array of distinct integers from to (inclusive).Example 1:Input: nums = [0,2,1,5,3,4]Output: [0,1,2,4,5,3]Exp原创 2023-09-05 01:36:23 · 286 阅读 · 0 评论 -
LeetCode --- 1913. Maximum Product Difference Between Two Pairs 解题报告
The product difference between two pairs and is defined as .Given an integer array , choose four distinct indices , , , and such that the product difference between pairs and is maximized.Return the maximum such product difference.Example 1:Input: nu原创 2023-09-03 03:07:36 · 386 阅读 · 0 评论 -
LeetCode --- 1909. Remove One Element to Make the Array Strictly Increasing 解题报告
Given a 0-indexed integer array , return if it can be made strictly increasing after removing exactly one element, or otherwise. If the array is already strictly increasing, return .The array is strictly increasing if for each index Example 1:Input: n原创 2023-09-03 02:40:04 · 130 阅读 · 0 评论 -
LeetCode --- 1903. Largest Odd Number in String 解题报告
You are given a string , representing a large integer. Return the largest-valued odd integer (as a string) that is a non-empty substring of , or an empty string if no odd integer exists.A substring is a contiguous sequence of characters within a string.Ex原创 2023-08-29 08:10:53 · 329 阅读 · 0 评论 -
LeetCode --- 1897. Redistribute Characters to Make All Strings Equal 解题报告
You are given an array of strings (0-indexed).In one operation, pick two distinct indices and , where is a non-empty string, and move any character from to any position in .Return if you can make every string in equal using any number of operations,原创 2023-08-21 00:42:42 · 606 阅读 · 0 评论 -
LeetCode --- 1893. Check if All the Integers in a Range Are Covered 解题报告
You are given a 2D integer array and two integers and . Each represents an inclusive interval between and .Return if each integer in the inclusive range is covered by at least one interval in . Return otherwise.An integer is covered by an interval原创 2023-08-15 23:52:53 · 246 阅读 · 0 评论 -
LeetCode --- 1886. Determine Whether Matrix Can Be Obtained By Rotation 解题报告
Given two binary matrices and , return if it is possible to make equal to by rotating in 90-degree increments, or otherwise.Example 1:Input: mat = [[0,1],[1,0]], target = [[1,0],[0,1]]Output: trueExplanation: We can rotate mat 90 degrees clockwis原创 2023-08-15 23:28:31 · 202 阅读 · 0 评论 -
LeetCode --- 1880. Check if Word Equals Summation of Two Words 解题报告
【代码】LeetCode --- 1880. Check if Word Equals Summation of Two Words 解题报告。原创 2023-08-09 22:49:11 · 935 阅读 · 0 评论 -
LeetCode --- 1876. Substrings of Size Three with Distinct Characters 解题报告
【代码】LeetCode --- 1876. Substrings of Size Three with Distinct Characters 解题报告。原创 2023-08-09 22:37:36 · 306 阅读 · 0 评论