注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
原题链接: 第一题: public class deleteAnnotation {
public static void main(String[] args) { String[] source = {"int a = 2;","int b = 47;/*37;*///41;","int c = 3/*4//5*/;","return a / b * c/*a/*b / c*/;"}; System.out.println(shortestSolutionLength(source)); }
private static int shortestSolutionLength(String[] source) { StringBuilder result = new StringBuilder(); for(String str : source){ result.append(str); result.append('\n'); } String res = result.toString(); String p = "(?<!:)\\/\\/.*|\\/\\*(\\s|.)*?\\*\\/"; String hehe = res.replaceAll(p,""); int num = 0; char[] ai = hehe.toCharArray(); for(int i = 0; i < ai.length; i++){ char temp = ai[i]; if(temp == ' ' || temp == '\n'){ continue; } num++; } return num; } }
第二题: package OA;
imp index].length() >= 1 && !(getarray[index].charAt(0) <= '9' && getarray[index].charAt(0) >= '0')){ result.add(getarray[index]); } } return result; }
private static boolean isValid(char charAt) { if((charAt >= 'a' && charAt <= 'z') || (charAt >= 'A' && charAt <= 'Z')){ return true; } if(charAt >= '0' && charAt <= '9') { return true; } if(charAt == '_') { return true; } return false; }
}
OA test cases全都过了。刚刚收到邮件说挂了,可能他们家放出new grad的岗位只是想让人去注册他们家网站吧。。。之前是店面秒解挂,现在是OA all pass 也挂。求转运~~
|