交换数组两个元素

超级幼稚的一道题,结果硬是纠结了好久:

题目链接:点击打开链接

代码:

python:

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
        a=A[index1]
        A[index1]=A[index2]
        A[index2]=a

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章