C++ simple solution 8 lines


  • 0
    class Solution {
    public:
        vector<int> sortTransformedArray(vector<int>& nums, int a, int b, int c) {
            vector<int> res;
            
            for (auto i : nums) {
                int val = a * i * i + b * i + c;
                auto it = lower_bound(res.begin(), res.end(), val);
                res.insert(it, val);
            }
            
            return res;
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.