自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

SnailTyan

纸上得来终觉浅,绝知此事要躬行。

  • 博客(918)
  • 资源 (3)
  • 收藏
  • 关注

原创 Leetcode 1408. String Matching in an Array

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def stringMatching(self, words: List[str]) -> List[str]: result = set() length = len(words) flags = [0 for

2021-06-29 14:28:39 75

原创 Leetcode 1721. Swapping Nodes in a Linked List

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def swapNodes(self, head: ListNode, k: int) -> ListNode: length = 0 ptr = head while ptr: leng

2021-06-29 14:26:58 96

原创 Leetcode 1023. Camelcase Matching

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def camelMatch(self, queries: List[str], pattern: str) -> List[bool]: result = [] for i in range(len(queries)):

2021-05-17 17:31:26 128

原创 Leetcode 804. Unique Morse Code Words

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def uniqueMorseRepresentations(self, words: List[str]) -> int: az = [chr(x) for x in range(ord('a'), ord('z') + 1)]

2021-05-17 17:31:17 138

原创 Leetcode 696. Count Binary Substrings

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def countBinarySubstrings(self, s: str) -> int: length = len(s) count = 0 pre = 0 curr = 1

2021-05-17 17:31:08 87

原创 Leetcode 383. Ransom Note

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def canConstruct(self, ransomNote: str, magazine: str) -> bool: ransom = Counter(ransomNote) mag = Counter(magazin

2021-05-17 17:30:47 112

原创 Leetcode 165. Compare Version Numbers

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def compareVersion(self, version1: str, version2: str) -> int: v1 = version1.split('.') v2 = version2.split('.')

2021-04-30 17:49:35 119 1

原创 Leetcode 235. Lowest Common Ancestor of a Binary Search Tree

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1# Definition for a binary tree node.# class TreeNode:# def __init__(self, x):# self.val = x# self.left = None# self.righ

2021-03-26 16:46:15 109

原创 Leetcode 172. Factorial Trailing Zeroes

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solution解析:Version 1简单,容易理解,但计算量大,耗时长。Version 2是只处理最后一位为0或5的情况,因为末尾所有的0都来自于这些数字。Version 3更进一步,变为统计数字中包含因子5的个数。Version 4则是统计数字中包含因子5,52,53,…,5^n的个数。Version 1class Solutio

2021-03-26 16:39:43 116

原创 Leetcode 336. Palindrome Pairs

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solution解析:Version 1简单,容易理解,但超时。Version 2是将字符串分为两部分,前半部分和后半部分,如果两部分有一部分是回文子串,则寻找另一部分的对应的回文字符串。Version 1class Solution: def palindromePairs(self, words): resu

2021-03-01 12:01:26 156 1

原创 Leetcode 706. Design HashMap

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class MyHashMap: def __init__(self): self.maps = [[] for _ in range(1000)] def put(self, key: int, value: int) -> None: ind

2021-02-25 17:55:08 114 1

原创 Leetcode 705. Design HashSet

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class MyHashSet: def __init__(self): self.hashset = [] def add(self, key: int) -> None: if key not in self.hashset:

2021-02-24 08:57:13 146

原创 Leetcode 726. Number of Atoms

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solution解析:这道题还有优化的空间,这样写主要是逻辑清晰。1. 把元素(多个字母)、数字(多个数字字符)、左右括号拆分开;2. 计算元素的个数,如果元素后没有数字,则添加数字1作为元素个数;当碰到右括号时,查找其对应的左括号,并将其中的元素个数乘以括号后的数字,其后没数字,则默认乘以1;3. 统计元素个数,相同元素个数相加;4. 排序字

2021-02-24 08:49:29 180

原创 Leetcode 939. Minimum Area Rectangle

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def minAreaRect(self, points): result = 0 stat = set(map(tuple, points)) for x1, y1 in points: f

2021-02-22 08:55:58 119

原创 Leetcode 811. Subdomain Visit Count

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def subdomainVisits(self, cpdomains): stat = {} for cpdomain in cpdomains: data = cpdomain.split(' ')

2021-02-22 08:51:12 110

原创 Leetcode 697. Degree of an Array

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1from collections import Counterclass Solution: def findShortestSubArray(self, nums): stat = Counter(nums) degree = 0 result

2021-02-22 08:51:08 104

原创 Leetcode 1413. Minimum Value to Get Positive Step by Step Sum

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def minStartValue(self, nums): min_value = nums[0] total = 0 for num in nums: total += num

2021-02-19 08:43:53 103

原创 Leetcode 1051. Height Checker

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def heightChecker(self, heights): count = 0 result = sorted(heights) for i in range(len(heights)): if

2021-02-19 08:43:44 107

原创 Leetcode 1002. Find Common Characters

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def commonChars(self, A): n = len(A) if n == 1: return [] result = sorted(A[0]) for i in

2021-02-09 18:19:31 118 1

原创 Leetcode 350. Intersection of Two Arrays II

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def intersect(self, nums1, nums2): nums1.sort() nums2.sort() m = len(nums1) n = len(nums2) i

2021-02-09 16:48:21 177

原创 Leetcode 349. Intersection of Two Arrays

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def intersection(self, nums1, nums2): result = set() for x in nums1: if x in nums2: resul

2021-02-09 11:50:57 118

原创 Leetcode 1481. Least Number of Unique Integers after K Removals

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def findLeastNumOfUniqueInts(self, arr, k): stat = {} for num in arr: stat[num] = stat.get(num, 0) + 1

2021-02-09 10:26:11 142

原创 Leetcode 368. Largest Divisible Subset

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def largestDivisibleSubset(self, nums): nums.sort() length = len(nums) dp = [1] * length for i in ran

2021-02-08 17:53:46 107

原创 Leetcode 1232. Check If It Is a Straight Line

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solution解析:直线的表示,可以用斜率式,也可以用两点式,Version 1是斜率式,Version 2是两点式。Version 1class Solution: def checkStraightLine(self, coordinates): diff_x = coordinates[-1][0] -

2021-02-08 15:24:45 119

原创 Leetcode 942. DI String Match

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def diStringMatch(self, S): n = len(S) left = 0 right = n result = [] for i in range(n + 1):

2021-02-08 14:45:08 134

原创 Leetcode 238. Product of Array Except Self

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solution解析:可以使用两个数组left, right分别保存从左边到第i个元素的积以及从右边到第i个元素的积,则结果中result[i]=left[i-1] * right[i+1],这种情况下的空间复杂度为O(n)。另一种方式是,计算左边元素积的同时更新结果数组,计算右边积的同时也更新结果数组,这种情况下的空间复杂度为O(1)。V

2021-02-07 14:54:46 153

原创 Leetcode 42. Trapping Rain Water

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solution解析:总的留存的雨水等于每个柱子上留存的雨水,而每个柱子上留存的雨水等于其左边最高柱子与右边最高柱子中较矮柱子的高度减去其高度。Version 1超时,Version 2是以空间换时间,Version 3是对Version 2的进一步优化。Version 1class Solution: def trap(sel

2021-02-07 14:36:30 235

原创 Leetcode 34. Find First and Last Position of Element in Sorted Array

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solution解析:最容易想到的就是二分查找,只是要进行一些修改,另一个方法是分别从前往后找以及从后往前找,满足条件就退出。Version 1class Solution: def searchRange(self, nums, target): length = len(nums) start

2021-02-05 18:18:33 192

原创 Leetcode 278. First Bad Version

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-PzF6AjOE-1612494708414)(http://noahsnail.com/images/leetcode/First_Bad_Version.png)]2. Solution解析:问题变为给定有序数组[1, 2, 2],找出第一个2的问题,最容易想到的就是二

2021-02-05 18:18:28 105

原创 Leetcode 374. Guess Number Higher or Lower

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solution解析:二分查找问题。class Solution: def guessNumber(self, n): left = 1 right = n while left <= right: mid = (left + right) // 2

2021-02-05 18:18:16 126

原创 Leetcode 658. Find K Closest Elements

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def findClosestElements(self, arr, k, x): result = [] index = self.binarySearch(arr, x) left = index

2021-02-05 18:17:26 103

原创 Leetcode 322. Coin Change

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def coinChange(self, coins, amount): if amount == 0: return 0 stat = [0] * (amount + 1) for i in

2021-02-04 18:01:01 125

原创 Leetcode 997. Find the Town Judge

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def findJudge(self, N, trust): if N == 1: return 1 if len(trust) < N - 1: return -1

2021-02-04 09:31:04 90

原创 Leetcode 171. Excel Sheet Column Number

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def titleToNumber(self, s): result = 0 mapping = {chr(64+i): i for i in range(1, 27)} s = list(s) s.r

2021-02-03 17:41:40 130

原创 Leetcode 168. Excel Sheet Column Title

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def convertToTitle(self, n): result = '' mapping = [chr(65+i) for i in range(0, 26)] while n: re

2021-02-03 17:22:45 94

原创 Leetcode 228. Summary Ranges

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def summaryRanges(self, nums): result = [] length = len(nums) i = 0 while i < length:

2021-02-03 15:04:35 114

原创 Leetcode 670. Maximum Swap

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solutionclass Solution: def maximumSwap(self, num): s = list(str(num)) length = len(s) if length < 2: return num for i in

2021-02-02 17:58:40 131

原创 Leetcode 321. Create Maximum Number

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solution解析:首先将问题分解为两个子问题,即分别求两个序列的最大值,得到两个子序列(保留顺序),两个子序列的长度和为k。合并两个子序列比较所有合并后的序列,返回值最大的序列Version 1class Solution: def maxNumber(self, nums1, nums2, k):

2021-02-02 17:17:26 138

原创 Leetcode 435. Non-overlapping Intervals

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. Solutionclass Solution: def eraseOverlapIntervals(self, intervals): count = 0 if len(intervals) < 2: return count intervals.sort(k

2021-02-02 09:34:36 100

原创 Leetcode 452. Minimum Number of Arrows to Burst Balloons

文章作者:Tyan博客:noahsnail.com  |  CSDN  |  简书1. Description2. SolutionVersion 1class Solution: def findMinArrowShots(self, points): if len(points) == 0: return 0 points.sort(key=lambda p: p[0])

2021-02-01 18:02:09 134

ntdll.lib文件

ntdll.lib是编译lmdb数据库时需要用到的静态库,在编译caffe时有用

2016-01-29

lmdb代码——caffe

lmdb,搭建caffe必备,少的东西我都添加上了,能直接生成

2016-01-27

Matlab/C++混合编程API

Matlab与C、C++进行混合编程的API手册,很有用,Matlab混合编程必备

2015-04-14

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除