class Solution:
"""
@param A: An integer array
@param index1: the first index
@param index2: the second index
@return: nothing
"""
def swapIntegers(self, A, index1, index2):
# write your code here
temp = A[index1]
A[index1] = A[index2]
A[index2] = temp
return APython, LintCode, 484. 交换数组两个元素
最新推荐文章于 2024-05-16 21:33:39 发布
本文介绍了一种简单的方法来交换数组中两个指定位置的整数。通过定义一个名为 swapIntegers 的函数,可以在不使用额外变量的情况下实现数组内整数的位置互换。此方法适用于需要频繁进行元素位置调整的场景。
3万+

被折叠的 条评论
为什么被折叠?



