Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
36 lines (34 loc) · 937 Bytes

File metadata and controls

36 lines (34 loc) · 937 Bytes
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.lintcode;
/**
* 49. 字符大小写排序
* 给定一个只包含字母的字符串,按照先小写字母后大写字母的顺序进行排序。
*
* 样例
给出"abAcD",一个可能的答案为"acbAD"
*/
public class Solution49 {
/*
* @param chars: The letter array you should sort by Case
* @return: nothing
*/
public void sortLetters(char[] chars) {
// write your code here
char temp = ' ';
int j = chars.length - 1;
for (int i = 0; i <= j; i++) {
if(Character.isLowerCase(chars[i])){
continue;
}else{
while(Character.isUpperCase(chars[j])){
if(j <= i){
break;
}
j --;
}
temp=chars[i];
chars[i]=chars[j];
chars[j]=temp;
}
}
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.