Given an array nums, write a function to move all 0’s to the end of it while maintaining the relative order of the non-zero elements. 12 Input: [0,1,0,3,12]Output: [1,3,12,0,0] solution 123456 s = [0,1,0,3,12]for i in range(0,len(s)): if s[i] == 0: s.remove(s[i]) s.append(0)print(s) 赞微海报分享
近期评论