Hello 算法 1.1.0 Python版。 # === File: array.py === def find(nums: list[int], target: int) -> int: """ 在数组中查找指定元素""" for i in range(len(nums)): if nums[i] == target: return i return -1 7. 扩容数组 在复杂的系统环境中,程序难以保证数组之后的内存 return head 5. 查找节点 遍历链表,查找其中值为 target 的节点,输出该节点在链表中的索引。此过程也属于线性查找。代码如下所 示: # === File: linked_list.py === def find(head: ListNode, target: int) -> int: """ 在链表中查找值为 target 的首个节点""" index = 0 while head: head: if head.val == target: return index head = head.next index += 1 return -1 4.2.2 数组 vs. 链表 表 4‑1 总结了数组和链表的各项特点并对比了操作效率。由于它们采用两种相反的存储策略,因此各种性质 和操作效率也呈现对立的特点。 表 4‑1 数组与链表的效率对比 数组 链表 存储方式0 码力 | 364 页 | 18.42 MB | 1 年前3
Hello 算法 1.0.0b5 Python版。 # === File: array.py === def find(nums: list[int], target: int) -> int: """ 在数组中查找指定元素""" for i in range(len(nums)): if nums[i] == target: return i return -1 7. 扩容数组 在复杂的系统环境中,程序难以保证数组之后的内存 遍历链表,查找链表内值为 target 的节点,输出节点在链表中的索引。此过程也属于线性查找。 # === File: linked_list.py === def find(head: ListNode, target: int) -> int: """ 在链表中查找值为 target 的首个节点""" index = 0 while head: if head.val == target: return 数据的有序性,每轮减少一半搜索 范围,直至找到目标元素或搜索区间为空为止。 � 给定一个长度为 ? 的数组 nums ,元素按从小到大的顺序排列,数组不包含重复元素。请查找 并返回元素 target 在该数组中的索引。若数组不包含该元素,则返回 −1 。 图 10‑1 二分查找示例数据 如图 10‑2 所示,我们先初始化指针 ? = 0 和 ? = ? − 1 ,分别指向数组首元素和尾元素,代表搜索区间0 码力 | 361 页 | 30.64 MB | 1 年前3
Hello 算法 1.0.0 Python版。 # === File: array.py === def find(nums: list[int], target: int) -> int: """ 在数组中查找指定元素""" for i in range(len(nums)): if nums[i] == target: return i return -1 7. 扩容数组 在复杂的系统环境中,程序难以保证数组之后的内存 return head 5. 查找节点 遍历链表,查找其中值为 target 的节点,输出该节点在链表中的索引。此过程也属于线性查找。代码如下所 示: # === File: linked_list.py === def find(head: ListNode, target: int) -> int: """ 在链表中查找值为 target 的首个节点""" index = 0 while head: head: if head.val == target: return index head = head.next index += 1 return -1 4.2.2 数组 vs. 链表 表 4‑1 总结了数组和链表的各项特点并对比了操作效率。由于它们采用两种相反的存储策略,因此各种性质 和操作效率也呈现对立的特点。 表 4‑1 数组与链表的效率对比 数组 链表 存储方式0 码力 | 362 页 | 17.54 MB | 1 年前3
Hello 算法 1.2.0 简体中文 Python 版。 # === File: array.py === def find(nums: list[int], target: int) -> int: """ 在数组中查找指定元素""" for i in range(len(nums)): if nums[i] == target: return i return -1 7. 扩容数组 在复杂的系统环境中,程序难以保证数组之后的内存 return head 5. 查找节点 遍历链表,查找其中值为 target 的节点,输出该节点在链表中的索引。此过程也属于线性查找。代码如下所 示: # === File: linked_list.py === def find(head: ListNode, target: int) -> int: """ 在链表中查找值为 target 的首个节点""" index = 0 while head: head: if head.val == target: return index head = head.next index += 1 return -1 4.2.2 数组 vs. 链表 表 4‑1 总结了数组和链表的各项特点并对比了操作效率。由于它们采用两种相反的存储策略,因此各种性质 和操作效率也呈现对立的特点。 表 4‑1 数组与链表的效率对比 数组 链表 存储方式0 码力 | 364 页 | 18.43 MB | 10 月前3
Conda 23.11.x Documentationlocation for an environment You can control where a conda environment lives by providing a path to a target directory when creating the environ- ment. For example, the following command will create a new environment version␣ ˓→that's newer than the conda currently being used. A newer version of conda is required. target environment location: /opt/conda current conda version: 4.5.9 minimum conda version: 4.6 116 Chapter thrice for DEBUG logging, four times for TRACE logging. -q, --quiet Do not display progress bar. Target Environment Specification -n, --name Name of environment. -p, --prefix Full path to environment0 码力 | 781 页 | 4.79 MB | 8 月前3
Conda 24.1.x Documentationlocation for an environment You can control where a conda environment lives by providing a path to a target directory when creating the environ- ment. For example, the following command will create a new environment version␣ ˓→that's newer than the conda currently being used. A newer version of conda is required. target environment location: /opt/conda current conda version: 4.5.9 minimum conda version: 4.6 114 Chapter thrice for DEBUG logging, four times for TRACE logging. -q, --quiet Do not display progress bar. Target Environment Specification -n, --name Name of environment. -p, --prefix Full path to environment0 码力 | 795 页 | 4.73 MB | 8 月前3
Conda 24.9.x DocumentationRelease 24.9.3.dev1 conda env list You can also use conda info --envs. Specifying a different target platform for an environment By default, conda will create environments targeting the platform it's the platform entry. However, in some cases you might want to create an environment for a different target platform or architecture. To do so, use the --platform flag available in the conda create and conda will be annotated with the custom configuration and subsequent operations on it will remember the target platform. This flag also allows specifying a different OS (e.g. creating a Linux environment on0 码力 | 799 页 | 5.26 MB | 8 月前3
Conda 23.7.x Documentationlocation for an environment You can control where a conda environment lives by providing a path to a target directory when creating the environ- ment. For example, the following command will create a new environment version␣ ˓→that's newer than the conda currently being used. A newer version of conda is required. target environment location: /opt/conda current conda version: 4.5.9 minimum conda version: 4.6 Solution for INFO, twice for DEBUG, three times for TRACE. -q, --quiet Do not display progress bar. 3.2.3 Target Environment Specification -n, --name Name of environment. -p, --prefix Full path to environment0 码力 | 795 页 | 4.91 MB | 8 月前3
Conda 25.1.x DocumentationRelease 25.1.2.dev1 conda env list You can also use conda info --envs. Specifying a different target platform for an environment By default, conda will create environments targeting the platform it's the platform entry. However, in some cases you might want to create an environment for a different target platform or architecture. To do so, use the --platform flag available in the conda create and conda will be annotated with the custom configuration and subsequent operations on it will remember the target platform. This flag also allows specifying a different OS (e.g. creating a Linux environment on0 码力 | 822 页 | 5.20 MB | 8 月前3
Conda 24.11.x DocumentationRelease 24.11.3.dev2 conda env list You can also use conda info --envs. Specifying a different target platform for an environment By default, conda will create environments targeting the platform it's the platform entry. However, in some cases you might want to create an environment for a different target platform or architecture. To do so, use the --platform flag available in the conda create and conda will be annotated with the custom configuration and subsequent operations on it will remember the target platform. This flag also allows specifying a different OS (e.g. creating a Linux environment on0 码力 | 818 页 | 5.21 MB | 8 月前3
共 446 条
- 1
- 2
- 3
- 4
- 5
- 6
- 45













