is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
public class Version {
- zhangzhuoqian October 06, 2013public static void main(String[] args){
List<String> list = new ArrayList<String>();
list.add("172.1.1");
list.add("172.1");
list.add("166");
list.add("178");
list.add("172.10.1");
list.add("172.11.1");
list.add("172.12.1");
list.add("172.2.1");
list.add("172.21.1");
list.add("172.3.1");
list.add("174.12.2");
list.add("174.1.22");
for (String version : sortVersions(list)) {
System.out.println(version);
}
}
private static List<String> sortVersions(List<String> list) {
Collections.sort(list, new VersionNumberComparator());
return list;
}
}
public class VersionNumberComparator implements Comparator<Object>{
@Override
public int compare(Object o1, Object o2) {
String a = (String) o1, b = (String) o2;
long ai = parseString(a);
long bi = parseString(b);
if(ai == bi){
return 0;
}
return ai>bi?1:-1;
}
private long parseString(String s){
int index = 0;
int versionIndex =1;
int digitIndex =1;
long value = 0;
int size = s.length();
for(;index<=size;index++){
if(index==size){
while(digitIndex<=3*versionIndex){
value *= 10;
digitIndex++;
}
}else if(s.charAt(index) == '.'){
while(digitIndex<=3*versionIndex){
value *= 10;
digitIndex++;
}
versionIndex++;
}else{
char a = s.charAt(index);
int digit = Character.getNumericValue(a);
value = digit+ value*10;
digitIndex++;
}
}
return value;
}
}