75. Sort Colors
来源:互联网 发布:ie8 js兼容性问题 编辑:程序博客网 时间:2024/06/05 13:35
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.
Note:
You are not suppose to use the library's sort function for this problem.
class Solution {public: void sortColors(vector<int>& nums) { for(int i=1;i<nums.size();i++) { int j=i; while(j>0&&nums[j-1]>nums[j]) { int temp=nums[j-1]; nums[j-1]=nums[j]; nums[j]=temp; j--; } } }};
阅读全文
0 0
- 【sort专题】75. Sort Colors
- 75. Sort Colors
- [LeetCode]75.Sort Colors
- LeetCode --- 75. Sort Colors
- [Leetcode] 75. Sort Colors
- [leetcode] 75.Sort Colors
- 75. Sort Colors
- 【leetcode】75. Sort Colors
- 75. Sort Colors
- [leetcode] 75. Sort Colors
- Leetcode 75. Sort Colors
- *LeetCode 75. Sort Colors
- 75. Sort Colors LeetCode
- 75. Sort Colors
- Leetcode 75. Sort Colors
- 75. Sort Colors
- [LeetCode]75. Sort Colors
- 75. Sort Colors
- oracle授权表权限给用户
- CentOS7.0下Redis的安装和部署
- 一:类的创建和销毁__构建器builder和javaBean
- 梯度下降法
- 业务 重于技术
- 75. Sort Colors
- 轻量级的Canvas类库zrender使用笔记 :简单自定义图件开发
- 关于spark UI界面的解释,非常清晰
- Caused by: java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.LoopTag
- 老外总结的高频PCB版的布线经验,值得一看!
- 一个经典的多线程同步问题
- 链表的删除
- xhr的jQuery方法
- 1.安装nginx