leetcode hot100强化练习 0 - 35

Part I 哈希表

1. 两数之和

class Solution(object):def twoSum(self, nums, target):""":type nums: List[int]:type target: int:rtype: List[int]"""if not nums:return d = {}for i, n in enumerate(nums):k = target - nif k not in d:d[n] = ielse:return [i, d[k]]        

2. 字母异位词分组

考察字符串的编码
ord函数:返回ascii码值

class Solution(object):def groupAnagrams(self, strs):""":type strs: List[str]:rtype: List[List[str]]"""def encode(s):code = [0] * 26for c in s:idx = ord(c) - ord('a')code[idx] += 1return ",".join([str(n) for n in code])d = {}for s in strs:x = encode(s)if x not in d:d[x] = [s]else:d[x].append(s)return d.values()

3. 最长连续序列

  1. HashSet的运用
class Solution(object):def longestConsecutive(self, nums):""":type nums: List[int]:rtype: int"""if not nums:return 0nums_set = set(nums)res = 1temp = 1for n in nums:if n - 1 in nums_set:# 找到连续序列的起点continue else:temp = 1while n + 1 in nums_set:n += 1temp += 1res = max(res, temp)return res

Part II 双指针

4. 移动零

快慢指针

class Solution(object):def moveZeroes(self, nums):""":type nums: List[int]:rtype: None Do not return anything, modify nums in-place instead."""slow, fast = 0, 0n = len(nums)while fast < n:if nums[fast] != 0:nums[slow], nums[fast] = nums[fast], nums[slow]slow += 1fast += 1return nums

5. 成水最多的容器

双指针,贪心。移动更短的柱子

class Solution(object):def maxArea(self, height):""":type height: List[int]:rtype: int"""n = len(height)if n <= 1:return 0left, right = 0, n-1res = 0cur = 0while left < right:cur = (right - left) * min(height[right], height[left])res = max(res, cur)if height[right] < height[left]:right -= 1else:left += 1return res

6. 三数之和

  1. 先排序
  2. 去重:相同的元素跳过(continue)
  3. 拆解成twoSum
class Solution(object):def threeSum(self, nums):""":type nums: List[int]:rtype: List[List[int]]"""def twoSum(nums, start, end, target):res2 = []lo, hi = start, endwhile lo < hi:                s = nums[lo] + nums[hi]if s > target:hi -= 1elif s < target:lo += 1else:res2.append([nums[lo], nums[hi]])lo += 1hi -= 1# 跳过重复元素while lo < hi and nums[lo] == nums[lo - 1]:lo += 1while lo < hi and nums[hi] == nums[hi + 1]:hi -= 1return res2if not nums:return nums.sort()res = []for i, n in enumerate(nums):if i > 0 and nums[i-1] == nums[i]:continueif n > 0:breaktemp = twoSum(nums, i+1, len(nums)-1, -n)for item in temp:res.append([n, item[0], item[1]]) return res

7. 接雨水

  1. 备忘录优化,O(n), O(n)
  2. 双指针往中间扩散,移动更短的柱子O(n), O(1)
class Solution(object):def trap(self, height):""":type height: List[int]:rtype: int"""if not height:return 0lmax, rmax = 0, 0lo, hi = 0, len(height)-1res = 0while lo <= hi:lmax = max(lmax, height[lo])rmax = max(rmax, height[hi])if lmax <= rmax:res += max(lmax-height[lo], 0)lo += 1else:res += max(rmax-height[hi], 0)hi -= 1return res            

Part III 滑动窗口

8. 无重复字符的最长子串

滑动窗口标准解法

class Solution(object):def lengthOfLongestSubstring(self, s):""":type s: str:rtype: int"""if not s:return 0n = len(s)lo, hi = 0, 0d = {}res = 0while hi < n:ch = s[hi]d[ch] = d.get(ch, 0) + 1while d.get(ch, 0) > 1:d[s[lo]] -= 1lo += 1hi += 1res = max(res, hi-lo)return res        

9. 找到字符串中的所有字母异位词

class Solution(object):def findAnagrams(self, s, p):""":type s: str:type p: str:rtype: List[int]"""if not s:return need = {}for c in p:need[c] = need.get(c, 0) + 1window = {}lo, hi = 0, 0n = len(s)res = []valid = 0while hi < n:c = s[hi]# hi += 1if c in need:window[c] = window.get(c, 0) + 1if window[c] == need[c]:valid += 1while hi - lo + 1 >= len(p):if valid == len(need):res.append(lo)d = s[lo]lo += 1if d in window and window[d] > 0:                    if window[d] == need[d]:valid -= 1window[d] -= 1hi += 1return res            

Part IV 子串

10. 和为k的子数组

前缀和,参考https://labuladong.online/algo/ds-class/shu-zu-lia-39fd9/jing-dian–52d44/

class Solution(object):def subarraySum(self, nums, k):""":type nums: List[int]:type k: int:rtype: int"""if not nums:return 0n = len(nums)preSum = [0 for _ in range(n+1)]for i in range(1, n+1):preSum[i] = preSum[i-1] + nums[i-1]val2idx = {}res = 0for i in range(0, n+1):                 if preSum[i]-k in val2idx:res += val2idx[preSum[i] - k]           val2idx[preSum[i]] = val2idx.get(preSum[i], 0) + 1            return res

11. 滑动窗口最大值

https://labuladong.online/algo/data-structure/monotonic-queue/
单调队列,加入数字的大小代表人的体重,体重大的会把前面体重不足的压扁,直到遇到更大的量级才停住。

class MonotonicQueue:def __init__(self):self.maxq = deque()def push(self, n):while len(self.maxq) > 0 and self.maxq[-1] < n:self.maxq.pop()self.maxq.append(n)def pop(self, n):if n == self.maxq[0]:self.maxq.popleft()def max(self):return self.maxq[0]
class Solution(object):def maxSlidingWindow(self, nums, k):""":type nums: List[int]:type k: int:rtype: List[int]"""if not nums:return mq = MonotonicQueue()for i in range(k):mq.push(nums[i])            res = [mq.max()]lo, hi = 0, k-1        while hi < len(nums)-1:hi += 1mq.push(nums[hi])mq.pop(nums[lo])lo += 1res.append(mq.max())        return res

12. 最小覆盖子串

滑动窗口解法

class Solution(object):def minWindow(self, s, t):""":type s: str:type t: str:rtype: str"""n, k = len(s), len(t)if n < k:return ""lo, hi = 0, 0valid = 0need, window = {}, {}for c in t:need[c] = need.get(c, 0) + 1res = ""while hi < n:c = s[hi]if c in need:window[c] = window.get(c, 0) + 1if window[c] == need[c]:valid += 1hi += 1while valid == len(need):                 if (not res) or len(res) > hi-lo:res = s[lo:hi]c = s[lo]if c in window:if window[c] == need[c]:valid -= 1window[c] -= 1lo += 1            return res                            

Part V 普通数组

13. 最大子数组和

https://leetcode.cn/problems/maximum-subarray/?envType=study-plan-v2&envId=top-100-liked
求最值 -> 第一时间想到动态规划,不要被滑动窗口带偏了
O(n), O(1)

class Solution(object):def maxSubArray(self, nums):""":type nums: List[int]:rtype: int"""if not nums:return 0n = len(nums)# d = [0 for _ in range(n)]d0 = nums[0]# d1 = 0res = d0for i in range(1, n):d1 = max(d0+nums[i], nums[i])d0 = d1res = max(res, d1)return res

14. 合并区间

https://leetcode.cn/problems/merge-intervals/?envType=study-plan-v2&envId=top-100-liked
区间问题合集:https://labuladong.online/algo/practice-in-action/interval-problem-summary/

  1. 排序,只对start排序即可,end无所谓
  2. 难点:找到res中最后一个区间last,在循环中更新last
class Solution(object):def merge(self, intervals):""":type intervals: List[List[int]]:rtype: List[List[int]]"""if not intervals:return intervals.sort(key = lambda x : (x[0]))res = [intervals[0]]for i in range(1, len(intervals)):last = res[-1]lo, hi = last[0], last[1]intv = intervals[i]            if intv[1] <= hi:passelif intv[0] <= hi and intv[1] > hi:res[-1] = [lo, intv[1]]else:res.append(intv)return res

15 轮转数组

O(n)解法:

class Solution(object):def rotate(self, nums, k):""":type nums: List[int]:type k: int:rtype: None Do not return anything, modify nums in-place instead."""n = len(nums)if not n:return temp = nums[:]for i in range(n):nums[(i+k)%n] = temp[i]

O(1): 翻转数组,比较难想;需要手动实现一个reverse函数

class Solution(object):def rotate(self, nums, k):""":type nums: List[int]:type k: int:rtype: None Do not return anything, modify nums in-place instead."""def reverse(nums, i, j):while i < j:nums[i], nums[j] = nums[j], nums[i]i += 1j -= 1n = len(nums)k = k%nreverse(nums, 0, n-1)reverse(nums, 0, k-1)reverse(nums, k, n-1)return nums

16 除自身以外数组的乘积

https://leetcode.cn/problems/product-of-array-except-self/description/?envType=study-plan-v2&envId=top-100-liked

和前缀和类似,新建两个数组L和R,记录左边和右边所有元素的乘积。
O(n), O(n)
空间O(1)的技巧有点trick,先不看了

class Solution(object):def productExceptSelf(self, nums):""":type nums: List[int]:rtype: List[int]"""n = len(nums)L, R = [1] * n , [1] * nfor i in range(1, n):L[i] = L[i-1] * nums[i-1]for i in range(n-2, -1, -1):R[i] = R[i+1] * nums[i+1]res = [0] * nfor i in range(n):res[i] = L[i] * R[i]return res

17. 缺失的第一个正数

https://leetcode.cn/problems/first-missing-positive/description/?envType=study-plan-v2&envId=top-100-liked

思路:将nums中所有数字放入哈希表,然后遍历1到n+1.
O(n),O(n).
空间O(1)的方法同样很trick了,感觉面试用不到先过

class Solution(object):def firstMissingPositive(self, nums):""":type nums: List[int]:rtype: int"""d = {}for n in nums:if n > 0 and n not in d:d[n] = 1for i in range(1, len(nums)+2):print(i)if i not in d:return i    

矩阵

18. 矩阵置零

https://leetcode.cn/problems/set-matrix-zeroes/description/?envType=study-plan-v2&envId=top-100-liked
O(mn), O(m+n)

class Solution(object):def setZeroes(self, matrix):""":type matrix: List[List[int]]:rtype: None Do not return anything, modify matrix in-place instead."""if not matrix:returnm, n = len(matrix), len(matrix[0])rows = [1 for i in range(m)]cols = [1 for i in range(n)]for i in range(m):for j in range(n):if matrix[i][j] == 0:rows[i] = 0cols[j] = 0for i in range(m):for j in range(n):matrix[i][j] *= rows[i]*cols[j]return matrix

O(1)方法:用矩阵的第一行和第一列代替rows和cols. 但要用额外的两个flag记录第一行和第一列是否有0. 感觉可读性变差很多,忽略。

19. 螺旋矩阵

https://leetcode.cn/problems/spiral-matrix/description/?envType=study-plan-v2&envId=top-100-liked

参考:二维数组的遍历技巧 https://labuladong.online/algo/practice-in-action/2d-array-traversal-summary/#%E7%9F%A9%E9%98%B5%E7%9A%84%E8%9E%BA%E6%97%8B%E9%81%8D%E5%8E%86

解题的核心思路是按照右、下、左、上的顺序遍历数组,并使用四个变量圈定未遍历元素的边界

class Solution(object):def spiralOrder(self, matrix):""":type matrix: List[List[int]]:rtype: List[int]"""if not matrix:returnm, n = len(matrix), len(matrix[0])upper_bound, lower_bound, left_bound, right_bound = 0, m-1, 0, n-1res = []while len(res) < m*n:if upper_bound <= lower_bound:for j in range(left_bound, right_bound+1):res.append(matrix[upper_bound][j])upper_bound += 1if right_bound >= left_bound:for i in range(upper_bound, lower_bound + 1):res.append(matrix[i][right_bound])right_bound -= 1if upper_bound <= lower_bound:for j in range(right_bound, left_bound-1, -1):res.append(matrix[lower_bound][j])lower_bound -= 1if right_bound >= left_bound:for i in range(lower_bound, upper_bound-1, -1):res.append(matrix[i][left_bound])left_bound += 1return res 

20 旋转二维图像

先按照左上->右下对角线翻转,再逐行翻转

class Solution(object):def rotate(self, matrix):""":type matrix: List[List[int]]:rtype: None Do not return anything, modify matrix in-place instead."""if not matrix:returnn = len(matrix)for i in range(n):for j in range(i+1, n):matrix[i][j], matrix[j][i]  = matrix[j][i], matrix[i][j]for i in matrix:i.reverse()return matrix

21 搜索二维数组

https://leetcode.cn/problems/search-a-2d-matrix-ii/description/?envType=study-plan-v2&envId=top-100-liked
二分搜索思想,从右上角开始。因为往左是变小,往下是变大,所以按照这个方向搜索即可。

class Solution(object):def searchMatrix(self, matrix, target):""":type matrix: List[List[int]]:type target: int:rtype: bool"""if not matrix:return Falsem, n = len(matrix), len(matrix[0])i, j = 0, n-1while i <= m-1 and j >= 0:if target == matrix[i][j]:return Trueelif target > matrix[i][j]:i += 1else:j -= 1return False

链表

22. 相交链表

https://leetcode.cn/problems/intersection-of-two-linked-lists/?envType=study-plan-v2&envId=top-100-liked

这道题不难,思路也都能想到。但具体实现的时候 while n1 != n2这个循环条件想了比较久。一开始想的是 while True,但没有跳出循环的条件。仔细想了下,n1和n2要么相交,要么都走向None,最终都是n1 == n2.

class Solution(object):def getIntersectionNode(self, headA, headB):""":type head1, head1: ListNode:rtype: ListNode"""n1, n2 = headA, headBwhile n1 != n2:if not n1:n1 = headBelse:n1 = n1.nextif not n2:n2 = headAelse:n2 = n2.nextreturn n1

23 反转链表

这道题的迭代解法必须熟练掌握,面试的时候保证自己5分钟内bug free写出来。因为后续很多题目会用到这个函数,还包括一些扩展,比如反转a、b两个结点之间的链表等等。

https://leetcode.cn/problems/reverse-linked-list/description/?envType=study-plan-v2&envId=top-100-liked

递归:O(n), O(n)
reverseList的功能:给定node,返回反转后node的头结点
因此需要做两件事:把head.next的next指向自己;把head.next断掉

class Solution(object):def reverseList(self, head):""":type head: ListNode:rtype: ListNode"""if not head or not head.next:return headlast = self.reverseList(head.next)head.next.next = head head.next = Nonereturn last

迭代:O(n), O(1)

class Solution(object):def reverseList(self, head):""":type head: ListNode:rtype: ListNode"""prev = Nonecur = head while cur:next = cur.nextcur.next = prevprev = curcur = nextreturn prev

24.回文链表

https://leetcode.cn/problems/palindrome-linked-list/description/?envType=study-plan-v2&envId=top-100-liked
存到数组里,O(n), O(n).

class Solution(object):def isPalindrome(self, head):""":type head: ListNode:rtype: bool"""if not head:return node = headnode2list = []while node:node2list.append(node.val)node = node.nextleft, right = 0, len(node2list)-1while left < right:if node2list[left] != node2list[right]:return Falseleft += 1right -= 1return True  

空间O(1):先找到中点,再用迭代法反转后半段链表,然后再双指针判断。太麻烦了

# Definition for singly-linked list.
# class ListNode(object):
#     def __init__(self, val=0, next=None):
#         self.val = val
#         self.next = next
class Solution(object):def isPalindrome(self, head):""":type head: ListNode:rtype: bool"""def reverse(node):if not node or not node.next:return nodeprev = Nonecur = nodewhile cur:# print("CUR:", cur)nxt = cur.nextcur.next = prevprev = curcur = nxtreturn previf not head or not head.next:return Trueslow, fast = head, head.nextwhile fast and fast.next:slow = slow.nextfast = fast.next.next# print(slow.val)slow.next = reverse(slow.next)p1, p2 = head, slow.nextwhile p1 and p2:if p1.val != p2.val:return Falsep1 = p1.nextp2 = p2.nextreturn True

25 环形链表 && ## 26 环形链表II

做了几百遍了略过

27 合并两个有序链表

直接双指针

class Solution(object):def mergeTwoLists(self, list1, list2):""":type list1: Optional[ListNode]:type list2: Optional[ListNode]:rtype: Optional[ListNode]"""n1 = list1n2 = list2dummy = ListNode(0)cur = dummywhile n1 and n2:if n1.val < n2.val:cur.next = n1n1 = n1.nextelse:cur.next = n2n2 = n2.nextcur = cur.nextif n1:cur.next = n1if n2:cur.next = n2return dummy.next

28 两数之和,链表版

https://leetcode.cn/problems/add-two-numbers/?envType=study-plan-v2&envId=top-100-liked

  1. 不要想着转化成数字相加,会溢出
  2. 注意while条件,carry要加上。否则最高一位进位后会丢数据
class Solution(object):def addTwoNumbers(self, l1, l2):""":type l1: ListNode:type l2: ListNode:rtype: ListNode"""      n1, n2 = l1, l2cur = 0carry = 0dummy = ListNode(0)res = dummywhile n1 or n2 or carry>0:cur = carryif n1:cur += n1.valn1 = n1.nextif n2:cur += n2.valn2 = n2.next            if cur >= 10:carry = 1cur = cur%10                else:carry = 0res.next = ListNode(cur)res = res.next      return dummy.next

29 删除链表的倒数第n个节点

双指针。注意n=sz的情况,用dummy处理虚拟头结点

class Solution(object):def removeNthFromEnd(self, head, n):""":type head: ListNode:type n: int:rtype: ListNode"""if not head:returnp1, p2 = head, headfor i in range(n):            p2 = p2.nextdummy = ListNode(0)dummy.next = headprev = dummywhile p2:prev = p1p1 = p1.nextp2 = p2.nextprev.next = p1.nextp1.next = Nonereturn dummy.next

30. 两两交换链表中的结点

迭代法,虚拟头结点。O(n), O(1)

class Solution(object):def swapPairs(self, head):""":type head: ListNode:rtype: ListNode"""if not head:returndummy = ListNode(0)dummy.next = headp1, p2 = head, head.nextprev = dummywhile p2:prev.next = p2nxt = p2.nextp2.next = p1p1.next = nxtp1, p2 =  p2, p1prev = p2p1 = p1.next.nextif p2.next and p2.next.next:p2 = p2.next.nextelse:breakreturn dummy.next

递归,O(n),O(n)
递归函数定义:给定头结点n,两两反转链表,然后返回头结点。好清晰

class Solution(object):def swapPairs(self, head):""":type head: ListNode:rtype: ListNode"""if not head or not head.next:return headp1, p2, p3 = head, head.next, head.next.nextp1.next = p2p2.next = p1p1.next = self.swapPairs(p3)return p2

31. k个一组反转链表

主要考察迭代法反转链表,以及递归的理解。

  1. 反转[a, b)之间的的链表
  2. 递归
class Solution(object):def reverseKGroup(self, head, k):""":type head: ListNode:type k: int:rtype: ListNode"""def reverse(p1, p2):if not p1 or not p1.next or p1 == p2 or p1.next == p2:return p1cur = p1prev = Nonewhile cur!= p2:nxt = cur.nextcur.next = prevprev  = curcur = nxtreturn previf not head or not head.next:return headp1, p2 = head, headfor i in range(k):if p2:p2 = p2.nextelse:return p1# 下面这几句是精华,用newHead记录反转后的头结点。此时p1是反转后的尾结点,p2是剩余链表的头结点。newHead = reverse(p1, p2)p1.next = self.reverseKGroup(p2, k)return newHead

32 随机链表的拷贝

https://leetcode.cn/problems/copy-list-with-random-pointer/description/?envType=study-plan-v2&envId=top-100-liked

难者不会会者不难。数据结构的拷贝:哈希表+两次遍历
第一次遍历,克隆结点,用哈希表把原结点和映射后结点对应存储起来;第二次遍历,组装结点,把next、random组装起来

class Solution(object):def copyRandomList(self, head):""":type head: Node:rtype: Node"""if not head:returnnode2dict = {}p = headwhile p:            node2dict[p] = Node(p.val)p = p.nextp = headwhile p:if p.next:node2dict[p].next = node2dict[p.next]if p.random:node2dict[p].random = node2dict[p.random]p = p.nextreturn node2dict[head]

33. 链表排序

https://leetcode.cn/problems/sort-list/?envType=study-plan-v2&envId=top-100-liked

  1. 首先复习一下归并排序 https://labuladong.online/algo/practice-in-action/merge-sort/
  2. 和数组相比,链表不用额外temp数组,会更方便
  3. 先找到链表中点,再分割,然后递归
class Solution(object):def sortList(self, head):""":type head: ListNode:rtype: ListNode"""def mergeSort(head):if not head or not head.next:return headmid = findMiddle(head)nxt = mid.nextmid.next = None                   p1 = mergeSort(head)p2 = mergeSort(nxt)          return merge(p1, p2)def findMiddle(head):slow, fast = head, head.nextwhile fast and fast.next:slow = slow.nextfast = fast.next.nextreturn slowdef merge(p1, p2):dummy = ListNode(0)cur = dummywhile p1 or p2:if not p1:cur.next = p2p2 = Noneelif not p2:cur.next = p1p1 = Noneelif p1.val < p2.val:cur.next = p1p1 = p1.nextelse:cur.next = p2p2 = p2.nextcur = cur.nextreturn dummy.nextreturn mergeSort(head)

34 合并k个升序链表

堆(优先队列),O(nlogk). k是优先队列的元素个数,一次push或者pop的时间复杂度为logk

class Solution(object):def mergeKLists(self, lists):""":type lists: List[ListNode]:rtype: ListNode"""import heapqpq = []for n in lists:if n:heapq.heappush(pq, (n.val, n))dummy = ListNode(0)cur = dummywhile pq:n = heapq.heappop(pq)[1]nxt = n.nextn.next = Nonecur.next = ncur = cur.nextif nxt:heapq.heappush(pq, (nxt.val, nxt))return dummy.next

35 LRU算法

数据结构:哈希链表。

  1. 先新建出Node和DoubleLinkedList的类,并写好初始化函数
  2. 从get和put逻辑开始倒推写。
class Node(object):def __init__(self, key, val):self.key = keyself.val = valself.next = Noneself.prev = None
class DoubleLinkedList(object):def __init__(self):self.head = Node(0, 0)self.tail = Node(0, 0)self.head.next = self.tailself.tail.prev = self.headself.size = 0def addLast(self, node):prv = self.tail.prevprv.next = nodenode.prev = prvnode.next = self.tailself.tail.prev = nodeself.size += 1def remove(self, node):if not node or not node.next or not node.prev:returnprv = node.prevnxt = node.nextprv.next = nxtnxt.prev = prvself.size -= 1def removeFirst(self):if self.size == 0:returnnode = self.head.nextnxt = node.nextself.head.next = nxtnxt.prev = self.headself.size -= 1return nodeclass LRUCache(object):def __init__(self, capacity):""":type capacity: int"""self.capacity = capacityself.hashMap = {}self.cache = DoubleLinkedList()def makeRecently(self, key):        node = self.hashMap[key]self.cache.remove(node)self.cache.addLast(node)def addRecently(self, key, val):node = Node(key, val)self.cache.addLast(node)self.hashMap[key] = nodedef deleteKey(self, key):if key not in self.hashMap:return Nonenode = self.hashMap[key]self.cache.remove(node)del self.hashMap[key]def removeLeastRecetly(self):node = self.cache.removeFirst()        del self.hashMap[node.key]        def get(self, key):""":type key: int:rtype: int"""if key not in self.hashMap:return -1else:            res = self.hashMap[key]self.makeRecently(key)return res.valdef put(self, key, value):""":type key: int:type value: int:rtype: None"""if key in self.hashMap:node = self.hashMap[key]node.val = valueself.makeRecently(key)else:if self.cache.size >= self.capacity:self.removeLeastRecetly()self.addRecently(key, value)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/20923.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

电子电器架构 --- 什么是域控制器?

我是穿拖鞋的汉子,魔都中坚持长期主义的汽车电子工程师。 老规矩,分享一段喜欢的文字,避免自己成为高知识低文化的工程师: 屏蔽力是信息过载时代一个人的特殊竞争力,任何消耗你的人和事,多看一眼都是你的不对。非必要不费力证明自己,无利益不试图说服别人,是精神上的节…

美颜相机与美图秀秀的非会员图片保存技巧畅享专业级图像处理探索

美颜相机与美图秀秀的非会员图片保存技巧畅享专业级图像处理探索 今日对美颜相机和美图秀秀的深入使用中&#xff0c;我遇到了一些功能限制&#xff0c;特别是在尝试保存特定处理后的图片时&#xff0c;发现通常需要开通VIP会员才能享受完整服务。作为一名热衷于技术探索的爱好…

【数据结构】二叉树的层序遍历~动画超详解

目录 1 什么是层序遍历2 二叉树层序遍历的基本思路3 二叉树层序遍历的实现 1 什么是层序遍历 我们从字面意思就明白,所谓层序,就是一层一层按顺序去遍历一个二叉树,这和我们之前了解的按前中后序遍历方式完全不同 比方说这颗二叉树: 前序遍历: 层序遍历: 2 二叉树层序遍历的…

深度解析Go语言中的Slice切片

深度解析Go语言中的Slice切片 一、 简介二、数据结构三、初始化四、内容截取五、切片扩容六、元素删除七、切片拷贝 一、 简介 go中的切片&#xff0c;在某种程度上相当于别的语言中的“数组”。不同点在于切片的长度和容量是可变的&#xff0c;在使用过程中可以进行扩容。 二…

Android 使用kotlin Retrofit2 + Dagger2完成网络请求跟依赖注入组合使用

文章目录 &#xff08;一&#xff09;引入依赖&#xff08;二&#xff09;基本概念Dagger中的基本概念&#xff1a;Retrofit介绍 &#xff08;三&#xff09;Dagger2 Module 和 Provides 和 Component Inject&#xff08;四&#xff09;Retrofit2 创建数据类Bean跟Service服务&…

探索Java反射:解密动态性与灵活性

前言 Java反射是一项强大而灵活的技术&#xff0c;它使得程序能够在运行时获取类的信息、调用类的方法、访问类的字段等。本篇博客将深入探讨Java反射的原理、应用场景以及使用技巧&#xff0c;带你解密Java反射的奥秘。 什么是Java反射&#xff1f; 在传统的Java编程中&…

LabVIEW调用国产硬件DLL的稳定性问题及解决方案

在LabVIEW中调用国内公司提供的硬件DLL时&#xff0c;尽管可以运行&#xff0c;但常出现不稳定和bug问题&#xff0c;且厂家临时修改的版本未经长期测试。为确保稳定性和质量&#xff0c;需要制定系统化的测试和反馈机制、建立严格的版本控制、与厂家协作优化、并进行深入的自测…

C语言刷题(数组)

1. 编写程序利用数组实现将一个数插入到一个有序的数列中&#xff0c;要求插入后仍有序。 C语言代码 #include <stdio.h> int main(){ int n 0; printf("请输入有序数组元素的个数&#xff1a;\n"); scanf("%d",&n); //定义并输入数组 …

3. MySQL 数据表的基本操作

文章目录 【 1. MySQL 创建数据表 】【 2. MySQL 查看表 】2.1 查看表的属性DESCRIBE/DESC 以表格的形式展示表属性SHOW CREATE TABLE 以SQL语句的形式展示表属性 2.2 查看表的内容 【 3. MySQL 修改数据表结构 】3.1 修改表名3.2 修改表字符集3.3 添加字段在末尾添加字段在开头…

LLMs Can’t Plan, But Can Help Planning in LLM-Modulo Frameworks

更多精彩内容&#xff0c;请关注微信公众号&#xff1a;NLP分享汇 原文链接&#xff1a;LLMs Can’t Plan, But Can Help Planning in LLM-Modulo Frameworks 你是怎么理解LLM的规划和推理能力呢&#xff0c;来自亚利桑那州立大学最近的一篇论文&#xff0c;对LLM的规划、推理…

RESTful API开发:Flask库设计用户认证接口的6个要点

在当今的Web开发世界里&#xff0c;RESTful API已然成为应用程序间数据交互的标准方式。它们简洁、灵活&#xff0c;使得前后端分离更加顺畅。而Flask&#xff0c;作为一款轻量级且功能强大的Python Web框架&#xff0c;无疑是构建RESTful API的理想工具。然而&#xff0c;要确…

Java面试题:如何在Java中实现线程间的通信?请列举几种常见的方式

在Java中&#xff0c;线程间的通信主要涉及到线程间的数据交换和协调。以下是几种常见的线程间通信方式&#xff1a; 共享对象&#xff1a; 线程可以通过共享对象的实例变量或方法参数来进行通信。这种方式需要特别注意线程安全&#xff0c;通常需要同步代码块或使用锁来避免并…

ios 新安装app收不到fcm推送

&#x1f3c6;本文收录于「Bug调优」专栏&#xff0c;主要记录项目实战过程中的Bug之前因后果及提供真实有效的解决方案&#xff0c;希望能够助你一臂之力&#xff0c;帮你早日登顶实现财富自由&#x1f680;&#xff1b;同时&#xff0c;欢迎大家关注&&收藏&&…

Python库之Playwright简介、安装、使用方法详细攻略

Python库之Playwright简介、安装、使用方法详细攻略 引言 在自动化测试领域&#xff0c;Playwright是一个强大的库&#xff0c;它支持无头浏览器自动化&#xff0c;允许开发者在多种浏览器上进行网页自动化操作。Playwright由微软开发&#xff0c;支持Chromium、Firefox和Web…

拼图游戏完整思路(全代码演示)

主界面 小练习1&#xff1a; 一、三个界面的设置1&#xff1a;创建窗体 1、将三个主界面分开为三个类&#xff0c;每个类都去继承JFrame这个类&#xff0c;使得每个类都可以使用创建页面功能 2、对每个类进行空参构造&#xff0c;在空参构造里面进行窗体属性的赋值 3、创建一个…

苍穹外卖--sky-take-out(二)3-5

sky-take-out&#xff08;一&#xff09;1-2https://blog.csdn.net/kussm_/article/details/138614737?spm1001.2014.3001.5501 第三天 公共字段填充--利用AOP 问题提出 这些字段属于公共字段 &#xff1a;在新增员工或者新增菜品分类时需要设置创建时间、创建人、修改时间…

蓝桥杯软件测试-十五届模拟赛2期题目解析

十五届蓝桥杯《软件测试》模拟赛2期题目解析 PS 需要第十五界蓝桥杯模拟赛2期功能测试模板、单元测试被测代码、自动化测试被测代码请加&#x1f427;:1940787338 备注&#xff1a;15界蓝桥杯省赛软件测试模拟赛2期 题目1&#xff1a;功能测试题目 1&#xff08;测试用例&…

[极速版]写个linux探测自己机器ip地址的tool(基于shell + sshpass)

适用情况&#xff1a;上级路由ssh or teamviewer访问下级路由的机器&#xff0c;但下级路由不支持查看IP 自行完成端口映射or DMZ整机映射 apt-get install sshpass#!/bin/bash mkdir log for i in $(seq 2 255) dosshpass -p tmp ssh -E err.log -o StrictHostKeyCheckingno …

【解决】Tree prefab at index 8 is missing.

开发平台&#xff1a;Unity 2020 版本以上   问题描述 翻译&#xff1a;树预制体集合中第8位预制体丢失。   解决方法&#xff1a;修复丢失树资产 关联 Unity Terrier 组件使用&#xff0c;前往 树绘制工作区&#xff0c;检查 “树资产” 引用是否丢失&#xff1f;删除或重…

【面试题-013】MyBatis 中,`#` 和 `$` 符号区别

在 MyBatis 中&#xff0c;# 和 $ 符号用于参数替换和表达式。它们在 SQL 语句中用于防止 SQL 注入&#xff0c;并允许动态地插入参数值。 # 符号&#xff08;预编译参数&#xff09;: #{parameter} 用于预编译参数。在 SQL 语句中&#xff0c;#{parameter} 会被 MyBatis 解析…