Remove Element

来源:互联网 发布:建筑工程成本核算软件 编辑:程序博客网 时间:2024/06/06 13:06

Given an array and a value, remove all instances of that value in place and return the new length.

The order of elements can be changed. It doesn't matter what you leave beyond the new length.

I think the description is not write in a clear way to understand...

I was using:

result = [j for i, j in enumerate(A) if j != elem]

A = result

but actually, this A still does not change... And I suddenly realized that it is not a hard copy.

need to check COPY!


0 0
原创粉丝点击