49. Sort Letters by Case】的更多相关文章

最后更新 一刷 还是Partition,只不过这次是按照大小写字母来. public class Solution { public void sortLetters(char[] chars) { //write your code here if (chars.length <= 1) return; int start = 0; int end = chars.length - 1; char min = 'Z'; char max = 'a'; while (start < end)…
Given a string which contains only letters. Sort it by lower case first and upper case second. Note It's not necessary to keep the original order of lower-case letters and upper case letters. Example For "abAcD", a reasonable answer is "acb…
Given a string which contains only letters. Sort it by lower case first and upper case second. Example For "abAcD", a reasonable answer is "acbAD" 与将负数都放在前面,正数都放在后面的题目一样. 时间复杂度为O(n) 找到第一大写字母,记录其下标为i,则小写字母必定在i之后出现,在i之后找到第一个出现的小写字母j.交换i,…
题目 字符大小写排序 给定一个只包含字母的字符串,按照先小写字母后大写字母的顺序进行排序. 您在真实的面试中是否遇到过这个题? Yes 样例 给出"abAcD",一个可能的答案为"acbAD" 注意 小写字母或者大写字母他们之间不一定要保持在原始字符串中的相对位置. 挑战 在原地扫描一遍完成 解题 这个题目很简单,前面刚做一个把大于某个数之和的排在后面,快速排序的思想 public class Solution { /** *@param chars: The le…
Yet Another Source Code for LintCode Current Status : 232AC / 289ALL in Language C++, Up to date (2016-02-10) For more problems and solutions, you can see my LintCode repository. I'll keep updating for full summary and better solutions. See cnblogs t…
Java Algorithm Problems 程序员的一天 从开始这个Github已经有将近两年时间, 很高兴这个repo可以帮到有需要的人. 我一直认为, 知识本身是无价的, 因此每逢闲暇, 我就会来维护这个repo, 给刷题的朋友们一些我的想法和见解. 下面来简单介绍一下这个repo: README.md: 所有所做过的题目 ReviewPage.md: 所有题目的总结和归纳(不断完善中) KnowledgeHash2.md: 对所做过的知识点的一些笔记 SystemDesign.md:…
[抄题]: Given a sorted array of integers nums and integer values a, b and c. Apply a quadratic function of the form f(x) = ax2 + bx + c to each element x in the array. The returned array must be in sorted order. Expected time complexity: O(n) Example 1…
case when 自定义排序时的使用 根据 case when 新的 sort字段排序 case when t2.status = 4 and t2.expire_time>UNIX_TIMESTAMP() and t2.expire_time<UNIX_TIMESTAMP(DATE_ADD(NOW(),INTERVAL 60 day)) then 4 when `status` = 2 then 3 when `status` = 3 then 2 when t2.status = 4 a…
转载:http://blog.csdn.net/sunshangjin/article/details/40296357 想起来自己天天排序排序,冒泡啊,二分查找啊,结果在STL中就自带了排序函数sort,qsort,总算把自己解脱了~ std::sort()函数的功能很强大,且可以对类,结构体等元素进行排序.C++sort参考手册 所以自己总结了一下,首先看sort函数见下表:参考csdn 函数名 功能描述 sort 对给定区间所有元素进行排序 stable_sort 对给定区间所有元素进行稳…
Bubble sort Bubble sort, sometimes incorrectly referred to as sinking sort, is a simple sorting algorithm that works by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items and swapping them if they are in the wron…