Compare commits
6 Commits
87bfcfbec5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| a432670752 | |||
| ca7709d9d8 | |||
| 8649325b7b | |||
| 0863bde155 | |||
| 8b0126ecb3 | |||
| 1fac510f07 |
5
.obsidian/core-plugins.json
vendored
5
.obsidian/core-plugins.json
vendored
@@ -27,5 +27,8 @@
|
||||
"publish": false,
|
||||
"sync": false,
|
||||
"bookmarks": true,
|
||||
"properties": false
|
||||
"properties": false,
|
||||
"webviewer": false,
|
||||
"footnotes": false,
|
||||
"bases": true
|
||||
}
|
||||
15
.obsidian/workspace.json
vendored
15
.obsidian/workspace.json
vendored
@@ -13,12 +13,12 @@
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Research/FSL/提示工程.md",
|
||||
"file": "Books/代码随想录/代码模版.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
},
|
||||
"icon": "lucide-file",
|
||||
"title": "提示工程"
|
||||
"title": "代码模版"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -70,8 +70,8 @@
|
||||
"state": {
|
||||
"type": "starred",
|
||||
"state": {},
|
||||
"icon": "lucide-file",
|
||||
"title": "Plugin no longer active"
|
||||
"icon": "lucide-ghost",
|
||||
"title": "starred"
|
||||
}
|
||||
},
|
||||
{
|
||||
@@ -185,6 +185,7 @@
|
||||
},
|
||||
"left-ribbon": {
|
||||
"hiddenItems": {
|
||||
"bases:Create new base": false,
|
||||
"switcher:Open quick switcher": false,
|
||||
"graph:Open graph view": false,
|
||||
"templates:Insert template": false,
|
||||
@@ -198,8 +199,9 @@
|
||||
},
|
||||
"active": "229ca4be3afd5932",
|
||||
"lastOpenFiles": [
|
||||
"Paper/FSL Image Classification/Context Attribute words for Prompt Tuning.md",
|
||||
"Books/代码随想录/代码模版.md",
|
||||
"Research/FSL/提示工程.md",
|
||||
"Paper/FSL Image Classification/Context Attribute words for Prompt Tuning.md",
|
||||
"Research/FSL",
|
||||
"Research",
|
||||
"conflict-files-obsidian-git.md",
|
||||
@@ -234,7 +236,6 @@
|
||||
"Books/动手学深度学习/基础概念.md",
|
||||
"liangOpenVocabularySemanticSegmentation2023.md",
|
||||
"Books/HDLBits/Verilog.md",
|
||||
"Record/Linux/常用软件.md",
|
||||
"Books/编译原理/Overview.md"
|
||||
"Record/Linux/常用软件.md"
|
||||
]
|
||||
}
|
||||
58
Books/代码随想录/代码模版.md
Normal file
58
Books/代码随想录/代码模版.md
Normal file
@@ -0,0 +1,58 @@
|
||||
# 数组
|
||||
## 二分
|
||||
```python
|
||||
def binary_search(nums, target):
|
||||
left, right = 0, len(nums) - 1
|
||||
while left <= right:
|
||||
mid = left + (right - left) // 2 # 防止溢出
|
||||
if nums[mid] == target:
|
||||
return mid # 找到目标,返回索引
|
||||
elif nums[mid] < target:
|
||||
left = mid + 1 # 目标在右半部分
|
||||
else:
|
||||
right = mid - 1 # 目标在左半部分
|
||||
return -1 # 未找到目标
|
||||
|
||||
# 左右边界
|
||||
def left_bound(nums, target):
|
||||
left, right = 0, len(nums) - 1
|
||||
while left <= right:
|
||||
mid = left + (right - left) // 2
|
||||
if nums[mid] < target:
|
||||
left = mid + 1
|
||||
else:
|
||||
right = mid - 1
|
||||
return left if left < len(nums) and nums[left] == target else -1
|
||||
def right_bound(nums, target):
|
||||
left, right = 0, len(nums) - 1
|
||||
while left <= right:
|
||||
mid = left + (right - left) // 2
|
||||
if nums[mid] <= target:
|
||||
left = mid + 1
|
||||
else:
|
||||
right = mid - 1
|
||||
return right if right >= 0 and nums[right] == target else -1
|
||||
```
|
||||
## 滑动窗口
|
||||
```python
|
||||
def lengthOfLongestSubstring(s: str) -> int:
|
||||
left = 0
|
||||
window = {}
|
||||
result = 0
|
||||
|
||||
for right in range(len(s)):
|
||||
char_right = s[right]
|
||||
window[char_right] = window.get(char_right, 0) + 1
|
||||
|
||||
# 当窗口中有重复字符时,收缩窗口
|
||||
while window[char_right] > 1:
|
||||
char_left = s[left]
|
||||
window[char_left] -= 1
|
||||
if window[char_left] == 0:
|
||||
del window[char_left]
|
||||
left += 1
|
||||
|
||||
result = max(result, right - left + 1)
|
||||
|
||||
return result
|
||||
```
|
||||
Reference in New Issue
Block a user