This commit is contained in:
krahets
2024-04-22 02:35:43 +08:00
parent e95b3bddf2
commit b3c757c9f4
14 changed files with 409 additions and 34 deletions

View File

@@ -92,7 +92,7 @@ comments: true
size := len(nums)
// 两层循环,时间复杂度为 O(n^2)
for i := 0; i < size-1; i++ {
for j := i + 1; i < size; j++ {
for j := i + 1; j < size; j++ {
if nums[i]+nums[j] == target {
return []int{i, j}
}

View File

@@ -1284,7 +1284,7 @@ comments: true
def is_empty(self) -> bool:
"""判断栈是否为空"""
return self._size == 0
return self.size() == 0
def push(self, item: int):
"""入栈"""