
Python
文章平均质量分 68
Python处理
优惠券已抵扣
余额抵扣
还需支付
¥9.90
¥99.00
购买须知?
本专栏为图文内容,最终完结不会低于15篇文章。
订阅专栏,享有专栏所有文章阅读权限。
本专栏为虚拟商品,基于网络商品和虚拟商品的性质和特征,专栏一经购买无正当理由不予退款,不支持升级,敬请谅解。
杨鑫newlfe
算法就是我的灵魂
展开
-
LeetCode --- 2269. Find the K-Beauty of a Number 解题报告
类似的题目一样是找到K-Beauty数字的定义,首先长度是k,然后能被num整除,那么直接模拟计算即可原创 2025-04-21 01:46:27 · 78 阅读 · 0 评论 -
LeetCode --- 2264. Largest 3-Same-Digit Number in String 结题报告
题意是给定一组字符串数字,判断是否包含三个连续的相同字符串,包含的话返回最大的,否则返回空字符串。这里直接打表即可。原创 2025-04-21 01:33:28 · 114 阅读 · 0 评论 -
LeetCode --- 2259. Remove Digit From Number to Maximize Result 解题报告
解题思路就是模拟remove操作,利用逻辑int(number[:i] + number[i+1:])找出符合对比的列表,取最大即可原创 2025-04-12 02:29:14 · 149 阅读 · 0 评论 -
LeetCode --- 2255. Count Prefixes of a Given String 解题报告
直接判断字符串前缀的逻辑startswith即可原创 2025-04-12 01:51:23 · 127 阅读 · 0 评论 -
LeetCode --- 2248. Intersection of Multiple Arrays 解题报告
首先为了取交集且因为大小的限制我们直接构造一个set(1...1000)然后利用Python的交集函数&直接几轮下来判断即可。原创 2025-04-09 00:39:34 · 63 阅读 · 0 评论 -
LeetCode --- 2243. Calculate Digit Sum of a String 解题报告
题目其实就是让你的代码进行规则模拟,按照给定的操作步骤进行分组,然后链接再次进行转换计算,直到拼接后的长度小于等于K即可。原创 2025-04-09 00:08:26 · 136 阅读 · 0 评论 -
LeetCode --- 2239. Find Closest Number to Zero 结题报告
直接将给定的数字按照与0的距离以及当前的大小做对比,然后对二元组进行取最大即可,这里为了满足顺序由小变大使用-负号进行计算直接取max(正数取到最大,负数取到最小)原创 2025-04-08 01:33:17 · 53 阅读 · 0 评论 -
LeetCode --- 2236. Root Equals Sum of Children 结题报告
就是计算先序遍历的二叉树计算两个子节点之和是否等于父节点之和原创 2025-04-08 01:16:33 · 65 阅读 · 0 评论 -
LeetCode --- 2235. Add Two Integers 解题报告
求和计算原创 2025-03-03 22:51:11 · 148 阅读 · 0 评论 -
LeetCode --- 2231. Largest Number After Digit Swaps by Parity 解题报告
Solution:总结是分治思想,其中我们要对所有的奇数和偶数排序。然后返回组合后最大的。我的思路是先记录每个元素是奇数还是偶数。然后分别对奇数偶数排序,最后按照记录的奇数偶数特性还原排序后的数组。原创 2025-03-03 22:45:40 · 224 阅读 · 0 评论 -
LeetCode --- 2224. Minimum Number of Operations to Convert Time 解题报告
Solutions:题意其实是要计算时间差,这里我们利用函数,把当前给定的两个字符串带入拼接datetime格式中利用时间差函数计算,在分别对已给定的60、15、5、1对比,即可知道转换了多少次原创 2025-03-02 23:42:53 · 106 阅读 · 0 评论 -
LeetCode --- 2220. Minimum Bit Flips to Convert Number 解题报告
Solution:题意是给定一两个数字start和goal,其中需要分别进行二进制转换这里使用format函数转换即可,然后再基于给定规则进行位数补充。最后对比差异值即可原创 2025-03-02 23:06:48 · 115 阅读 · 0 评论 -
LeetCode --- 2215. Find the Difference of Two Arrays 解题报告
Solution:题意是给定了两组字符串数组,其中返回按照要求的结果值。结果1要求是,数组一中的返回结果唯一,且该元素不再数组2中出现;结果2要求是,数组二中的返回结果唯一,且该元素不再数组1中出现;直接打表返回即可。原创 2025-02-20 00:20:29 · 92 阅读 · 0 评论 -
LeetCode --- 2210. Count Hills and Valleys in an Array 解题报告
Solution:题意是给定两个指标定义hills:nums[i - 1] < nums[i] and nums[i] > nums[i + 1]valleys:nums[i - 1] > nums[i] and nums[i] < nums[i + 1]如果满足上面任何一个,即可累加,最后返回符合条件的累加结果原创 2025-02-18 01:53:30 · 206 阅读 · 0 评论 -
LeetCode --- 2206. Divide Array Into Equal Pairs 解题报告
Solution:题意其实是给定一组n * 2长度的数组,判断是否可以拆分成如下多个元祖1.每个元素只属于一对。2.成对的元素是相等的。这里直接统计每个元素的数量,然后遍历判断即可原创 2025-02-18 01:11:25 · 84 阅读 · 0 评论 -
LeetCode --- 2200. Find All K-Distant Indices in an Array 解题报告
题意就是给定一个数组,找到这个数组中符合|i - j| <= k and nums[j] == key的下标 返回下标即可原创 2025-02-11 23:02:11 · 222 阅读 · 0 评论 -
LeetCode --- 2194. Cells in a Range on an Excel Sheet 解题报告
题意是给定一组坐标,通过计算列出所有中间的元素。其中数字和字符转换通过chr()和ord()转换原创 2025-02-10 00:12:45 · 202 阅读 · 0 评论 -
LeetCode --- 2190. Most Frequent Number Following Key In an Array 解题报告
题目其实不是很好理解,英文对中文太绕了。这里简单解读下,给定一个字符串数组nums,和一个目标数字Key,其中我们要定义几个概念:目标值:key要求在给定的数组nums中存在。然后我们要统计出了key之后的元素这里从i + 1开始,首先 i + 1 小于给定的长度,这里原本要求是 i < 0 <= i <= nums.length - 2,....原创 2025-02-01 14:21:23 · 280 阅读 · 0 评论 -
LeetCode --- 2185. Counting Words With a Given Prefix 解题报告
题意说道是给定一组字符串,和一个前缀字符串pref,我们判断给定数组中的字符串如果包含这个前缀的,记一个。最后看下有多少个字符串符合这个规则即可原创 2025-02-01 13:30:00 · 544 阅读 · 0 评论 -
LeetCode --- 1637. Widest Vertical Area Between Two Points Containing No Points 解题报告
题意是找到给定的坐标中两个宽度最大的(其实就是X轴或者横坐标距离最大的)。这里直接取出来所有点的横坐标然后进行排期,直接判断最大的距离即可。原创 2025-01-31 19:28:36 · 54 阅读 · 0 评论 -
LeetCode --- 2180. Count Integers With Even Digit Sum 解题报告
题意是给定一个数字num,需要统计下小于等于num的数字符合每个元素求和是偶数的。原创 2025-01-31 18:56:32 · 417 阅读 · 0 评论 -
LeetCode --- 2176. Count Equal and Divisible Pairs in an Array 解题报告
题意是给定一组数组,其中如果元素相同的情况下,下标还可以相乘且可以被K除情况下,统计有多少组。这里直接打表完成计算。原创 2025-01-30 08:51:58 · 383 阅读 · 0 评论 -
LeetCode --- 2169. Count Operations to Obtain Zero 解题报告
题意是给定两个数字,如果两个数字都大于0的话,都需要进行减法(大的减去小的),然后再进行比较依次反复。最后出现有一个小于等于0,就结束计算,最后只需要统计出一共计算了多少次即可。直接模拟打表操作。原创 2025-01-29 20:42:39 · 544 阅读 · 0 评论 -
LeetCode --- 2164. Sort Even and Odd Indices Independently 解题报告
You are given a 0-indexed integer array . Rearrange the values of according to the following rules:Return the array formed after rearranging the values of .Example 1:Input: nums = [4,1,2,3]Output: [2,3,4,1]Explanation: First, we sort the values presen原创 2025-01-09 23:59:17 · 287 阅读 · 0 评论 -
LeetCode --- 2160. Minimum Sum of Four Digit Number After Splitting Digits 解题报告
You are given a positive integer consisting of exactly four digits. Split into two new integers and by using the digits found in . Leading zeros are allowed in and , and all the digits found in must be used.Return the minimum possible sum of and .Ex原创 2024-11-25 01:49:55 · 268 阅读 · 0 评论 -
LeetCode --- 2154. Keep Multiplying Found Values by Two 解题报告
You are given an array of integers . You are also given an integer which is the first number that needs to be searched for in .You then do the following steps:Return the final value of .Example 1:Input: nums = [5,3,6,1,12], original = 3Output: 24Explan原创 2024-07-30 23:31:16 · 189 阅读 · 0 评论 -
LeetCode --- 2148. Count Elements With Strictly Smaller and Greater Elements 解题报告
Given an integer array , return the number of elements that have both a strictly smaller and a strictly greater element appear in .Example 1:Input: nums = [11,7,2,15]Output: 2Explanation: The element 7 has the element 2 strictly smaller than it and the原创 2024-07-18 01:58:39 · 3784 阅读 · 0 评论 -
LeetCode --- 2144. Minimum Cost of Buying Candies With Discount 解题报告
A shop is selling candies at a discount. For every two candies sold, the shop gives a third candy for free.The customer can choose any candy to take away for free as long as the cost of the chosen candy is less than or equal to the minimum cost of the two原创 2024-07-18 01:30:58 · 728 阅读 · 0 评论 -
LeetCode --- 2138. Divide a String Into Groups of Size k 解题报告
A string can be partitioned into groups of size using the following procedure:Note that the partition is done so that after removing the character from the last group (if it exists) and concatenating all the groups in order, the resultant string should原创 2024-07-16 23:15:32 · 9121 阅读 · 0 评论 -
LeetCode --- 2133. Check if Every Row and Column Contains All Numbers 解题报告
An matrix is valid if every row and every column contains all the integers from to (inclusive).Given an integer matrix , return if the matrix is valid. Otherwise, return .Example 1:Input: matrix = [[1,2,3],[3,1,2],[2,3,1]]Output: trueExplanation: I原创 2024-07-16 01:33:55 · 152 阅读 · 0 评论 -
LeetCode --- 2129. Capitalize the Title 解题报告
You are given a string consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the string by changing the capitalization of each word such that:Return the capitalized .Example 1:Input: title =原创 2024-07-16 01:17:04 · 1708 阅读 · 0 评论 -
LeetCode --- 2124. Check if All A‘s Appears Before All B‘s 解题报告
Given a string consisting of only the characters and , return if every appears before every in the string. Otherwise, return .Example 1:Input: s = "aaabbb"Output: trueExplanation:The 'a's are at indices 0, 1, and 2, while the 原创 2024-07-11 22:47:58 · 666 阅读 · 0 评论 -
LeetCode --- 2119. A Number After a Double Reversal 解题报告
Reversing an integer means to reverse all its digits.Given an integer , reverse to get , then reverse to get . Return if equals . Otherwise return .Example 1:Input: num = 526Output: trueExplanation: Reverse num to get 625, then reverse 625 to get 52原创 2024-07-10 23:25:32 · 409 阅读 · 0 评论 -
LeetCode --- 2114. Maximum Number of Words Found in Sentences 解题报告
A sentence is a list of words that are separated by a single space with no leading or trailing spaces.You are given an array of strings , where each represents a single sentence.Return the maximum number of words that appear in a single sentence.Example 1原创 2024-07-10 23:03:37 · 541 阅读 · 0 评论 -
LeetCode --- 2108. Find First Palindromic String in the Array 解题报告
Given an array of strings , return the first palindromic string in the array. If there is no such string, return an empty string .A string is palindromic if it reads the same forward and backward.Example 1:Input: words = ["abc","car",&原创 2024-07-09 00:23:27 · 2931 阅读 · 0 评论 -
LeetCode --- 2103. Rings and Rods 解题报告
There are rings and each ring is either red, green, or blue. The rings are distributed across ten rods labeled from to .You are given a string of length that describes the rings that are placed onto the rods. Every two characters in forms a color-pos原创 2024-07-08 00:03:11 · 283 阅读 · 0 评论 -
LeetCode --- 2099. Find Subsequence of Length K With the Largest Sum 解题报告
You are given an integer array and an integer . You want to find a subsequence of of length that has the largest sum.Return any such subsequence as an integer array of length .A subsequence is an array that can be derived from another array by deleting原创 2024-07-06 02:10:34 · 220 阅读 · 0 评论 -
LeeCode --- 2094. Finding 3-Digit Even Numbers 解题报告
You are given an integer array , where each element is a digit. The array may contain duplicates.You need to find all the unique integers that follow the given requirements:For example, if the given were , integers and follow the requirements.Return a s原创 2024-07-05 00:19:59 · 337 阅读 · 0 评论 -
Leetcode --- 2089. Find Target Indices After Sorting Array 解题报告
You are given a 0-indexed integer array and a target element .A target index is an index such that .Return a list of the target indices of after sorting in non-decreasing order. If there are no target indices, return an empty list. The returned list mu原创 2024-07-04 23:51:55 · 102 阅读 · 0 评论 -
LeetCode --- 2085. Count Common Words With One Occurrence 解题报告
Given two string arrays and , return the number of strings that appear exactly once in each of the two arrays.Example 1:Input: words1 = ["leetcode","is","amazing","as","is"], words2 = ["amazing"原创 2024-07-04 00:23:22 · 472 阅读 · 0 评论