Python Array Rotation

前端 未结 7 1315
夕颜
夕颜 2020-12-03 08:24

So I am implementing a block swap algorithm in python.

The algorithm I am following is this:

Initialize A = arr[0..d-1] and B = arr[d..n-1] 1) Do following u

7条回答
  •  甜味超标
    2020-12-03 08:32

    Do you actually need to implement the block swap or are you just looking to rotate the array? In python you can do CW and CWW rotations using

    zip(*arr[::-1])
    

    and

    zip(*arr)[::-1]
    

提交回复
热议问题