吉比特笔试:Java开发工程师
- 选择题:20道选择题,题目难度不大
- 填空题:5个填空题,都是阅读程序题,c++的代码,时间来不及,猜了
- 编程题:2道题。
1. 给定一个英文字母组成的字符串,对于字符串中字母,如果前面已经出现过,字母不区分大小写,则需要将其删除,输出删除后的字符串过
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
String result = solution(str);
System.out.println(result);
}
public static String solution(String str) {
List<Character> list = new ArrayList<>();
String result = "";
String up = str.toUpperCase();
String lower = str.toLowerCase();
for (int i = 0; i < str.length(); i++) {
// 大小写问题
if (!(list.contains(up.charAt(i)) || list.contains(lower.charAt(i)))) {
list.add(str.charAt(i));
}
}
//链表转换成字符串,并进行拼接
StringBuilder sb = new StringBuilder();
for (int j = 0; j < list.size(); j++) {
sb.append(list.get(j));
}
result = sb.toString();
return result;
}
} 2.需要统计所有满足下列条件的长度为n的字符串的个数,ABCD
相关链接:
List转换成String字符串三种方式
#吉比特##笔经##校招##Java工程师#
查看30道真题和解析