LeetCode #2161

Partition Array According to Given Pivot

1개의 풀이 · C++

문제 원문 보기 ↗

SOLUTION INFO

C++ · main.cpp

main.cpp
class Solution {
public:
    vector<int> pivotArray(vector<int>& nums, int pivot) {
        vector<int> L, M, R;
        for(const int &x: nums) {
            if(x < pivot) L.push_back(x);
            else if(x == pivot) M.push_back(x);
            else R.push_back(x);
        }
        for(const int &x: M) L.push_back(x);
        for(const int &x: R) L.push_back(x);
        return L;
    }
};

SOLUTION DESCRIPTION

풀이 설명

등록된 풀이 설명이 없습니다.