[刷题]Sort Colors II
来源:互联网 发布:java中数组特点 编辑:程序博客网 时间:2024/06/04 19:30
[LintCode]Sort Colors II
class Solution { /** * @param colors: A list of integer * @param k: An integer * @return: nothing */ public void sortColors2(int[] colors, int k) { // 2015-09-15 if (colors == null || colors.length == 0 || k < 2) { return; } int[] list = new int[k]; for (int i = 0; i < colors.length; i++) { list[colors[i] - 1]++; } int index = 0; for (int i = 0; i < list.length; i++) { for (int j = 0; j < list[i]; j++) { colors[index++] = i + 1; } } return; }}
0 0
- [刷题]Sort Colors II
- Lintcode - sort colors II
- sort-colors-ii
- lintcode:Sort Colors II
- Sort Colors II
- #143 Sort Colors II
- [LintCode]Sort Colors II
- LintCode 143. Sort Colors II
- [刷题]Sort Colors
- [Leetcode刷题]Sort Colors
- 143.Sort Colors II-排颜色 II(中等题)
- Sort Colors
- sort colors
- Sort Colors
- Sort Colors
- Sort Colors
- Sort Colors
- Sort Colors
- boss给的课后作业:敏捷开发
- 【Android】Android清除本地数据缓存代码
- HDR&Filmic Tonemapping Operators
- 驱动学习--SYS属性节点创建
- getContextPath、getServletPath、getRequestURI的区别
- [刷题]Sort Colors II
- 关于phpMail无法发送邮件问题
- .NET基础--if-else与swirch的区别
- 记录一些UIScrollView的代理方法
- 双向链表的实现
- Leetcode: Zigzag Iterator
- IOS AFNetworking https
- WebRTC
- Android代码优化(一)