LeetCode:75. Sort Colors

xiaoxiao2021-02-28  87

Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.

Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respectively.

这道题感觉自己用了一个sort的算法,然后就OK了。

AC:

class Solution { public: void sortColors(vector<int>& nums) { sort(nums.begin(),nums.end()); } };

转载请注明原文地址: https://www.6miu.com/read-39337.html

最新回复(0)