交換數組兩個元素

超級幼稚的一道題,結果硬是糾結了好久:

題目鏈接:點擊打開鏈接

代碼:

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

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