728x90
stable_partition
-
[LeetCode] 283. Move Zeroes c++Coding Test/LeetCode 2022. 12. 24. 17:54
문제 Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. Input: nums = [0,1,0,3,12] Output: [1,3,12,0,0] 문제 해결 처음에는 벡터 원소에 0이 있으면 삭제하는 문제인 줄 알았다. remove_if() 함수를 사용해서 0이라면 삭제하는 코드를 작성했다. class Solution { public: static bool oper(const int& a){ if( a == 0){ r..