はじめに
配列の削除について考察してみた
配列を分割して削除
n,m = map(int,input().split())
array1 = input().split()
array2 = array1.pop(m-1)
for i in array1:
print(i)
配列を2つに分割して元の削除の特定の要素を削除したかのようにする
削除した要素は別の配列に格納される。
配列の要素を削除
values = input().split()
N = int(values[0])
M = int(values[1])
A = [0] * N
values = input().split()
for i in range(N):
A[i] = int(values[i])
del A[M - 1]
for a in A:
print(a)
特定の要素を削除している。
まとめ
後者の方がメモリ量は低い