n := len(nums)
ans := make([]int, n)
i, j := 0, n-1
for pos := n - 1; pos >= 0; pos-- {
if v, w := nums[i]*nums[i], nums[j]*nums[j]; v > w {
ans[pos] = v
i++
} else {
ans[pos] = w
j--
}
}
return an
解题要点:在数组中旋转操作,离不开 mod 的计算,避免移出,通过k mod n,得到最后少于 n 的数,让里面每个数字,都移动k mod n 位,下次循环替换,next位
n := len(nums)
k %= n
for start, count := 0, gcd(k, n); start < count; start++ {
pre, cur := nums[start], start
fmt.Println("1=1", pre, cur, start)
for ok := true; ok; ok = cur != start {
next := (cur + k) % n
// 关键点在这里
nums[next], pre, cur = pre, nums[next], next
fmt.Println("2=2", nums, next, pre, cur)
}
}
二分查找,三个值,left,mid,right,mid 通过 left + (right - left )/2 计算出来,如果某个值大于target值,则向right向左边走,也就是right = mid - 1 否则 left 右边走
left, right := 0, len(nums)-1
mid := left
for left <= right {
mid = left + (right-left)/2
fmt.Println(nums[mid], left, mid, right)
if nums[mid] == target {
return mid
} else if nums[mid] > target {
right = mid - 1
} else if nums[mid] < target {
left = mid + 1
}
}
空间换时间
if p, ok := hashMap[target-num]; ok {
return []int{p, i}
}
hashMap[num] = i
fmt.Println(hashMap)
RROR: Cannot uninstall 'requests'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
pip install --ignore-installed requests
等任何错误都使用这个方式进行修复
pip uninstall requests
yum reinstall python-requests
pip uninstall six
yum reinstall python-six
pip uninstall urllib3
yum reinstall python-urllib3
参考资料
https://dbillinghamuk.medium.com/certbot-certificate-verification-through-nginx-container-710c299ec549
https://medium.com/@getpagespeed/fix-importerror-pyopenssl-module-missing-required-functionality-e1c514797204