【JAVA】騰訊2021校園招聘-後臺&綜合-第二次筆試
這裡寫目錄標題
前言
祝所有人都有理想的offer,offer拿到手軟,you can, you can fly,you can,you can catch the stars,you can stand shoulder to shoulder with the sun
一、連結串列的公共部分(全A)
程式碼
package tengxun;
import java.util.Scanner;
/**
* Created by IntelliJ IDEA.
*
* @Author:
* @Email:
* @Date: 2020/9/6
* @Time: 20:03
* @Version: 1.0
* @Description: Description
*/
public class First {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr1 = new int[n];
for (int i = 0; i < n; i++) {
arr1[i] = sc.nextInt();
}
int m = sc.nextInt();
int[] arr2 = new int[m];
for (int i = 0; i < m; i++) {
arr2[i] = sc.nextInt();
}
sc.close();
int p1 = 0, p2 = 0;
while (p1 < n && p2 < m) {
if (arr1[p1] == arr2[p2]) {
System.out.print(arr1[p1] + " ");
p1++;
p2++;
} else if (arr1[p1] < arr2[p2]) {
p2++;
} else {
p1++;
}
}
}
}
二、通知傳遞(全A)
程式碼
package tengxun;
import java.util.HashSet;
import java.util.Scanner;
/**
* Created by IntelliJ IDEA.
*
* @Author:
* @Email:
* @Date: 2020/9/6
* @Time: 20:46
* @Version: 1.0
* @Description: Description
*/
public class Second {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
int[][] teams = new int[m][];
for (int i = 0; i < m; i++) {
int len = sc.nextInt();
int[] team = new int[len];
for (int j = 0; j < len; j++) {
team[j] = sc.nextInt();
}
teams[i] = team;
}
sc.close();
HashSet<Integer> knows = new HashSet<>();
knows.add(0);
for (int k = 0; k < m; k++) {
for (int i = 0; i < m; i++) {
for (int j = 0; j < teams[i].length; j++) {
if (knows.contains(teams[i][j])) {
for (int j2 = 0; j2 < teams[i].length; j2++) {
knows.add(teams[i][j2]);
}
break;
}
}
}
}
System.out.println(knows.size());
}
}
三、字串次數(A0.6)
程式碼
package tengxun;
import java.util.HashMap;
import java.util.Scanner;
/**
* Created by IntelliJ IDEA.
*
* @Author:
* @Email:
* @Date: 2020/9/6
* @Time: 21:12
* @Version: 1.0
* @Description: Description
*/
public class Third {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
HashMap<String, Integer> map1 = new HashMap<>();
while (n-- > 0) {
String str = sc.next();
map1.put(str, map1.getOrDefault(str, 0) + 1);
}
sc.close();
int max = 0;
String maxString = null;
HashMap<String, Integer> map2 = (HashMap<String, Integer>) map1.clone();
for (int i = 0; i < k; i++) {
for (String string2 : map2.keySet()) {
if (map2.get(string2) > max ||
(map2.get(string2) == max && string2.compareTo(maxString) < 0)) {
max = map2.get(string2);
maxString = string2;
}
}
map2.remove(maxString);
System.out.println(maxString + " " + max);
max = 0;
}
int min = Integer.MAX_VALUE;
String minString = null;
for (int i = 0; i < k; i++) {
for (String string1 : map1.keySet()) {
if (map1.get(string1) < min ||
(map1.get(string1) == min && string1.compareTo(minString) < 0)) {
min = map1.get(string1);
minString = string1;
}
}
map1.remove(minString);
System.out.println(minString + " " + min);
min = Integer.MAX_VALUE;
}
}
}
四、中位數(全A)
程式碼
package tengxun;
import java.util.Arrays;
import java.util.Scanner;
/**
* Created by IntelliJ IDEA.
*
* @Author:
* @Email:
* @Date: 2020/9/6
* @Time: 20:25
* @Version: 1.0
* @Description: Description
*/
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = sc.nextInt();
}
sc.close();
int[] arr1 = arr.clone();
Arrays.sort(arr);
// System.out.println(Arrays.toString(arr));
// System.out.println(Arrays.toString(arr1));
int a = arr[n / 2 - 1];
int b = arr[n / 2];
for (int i = 0; i < n; i++) {
if (arr1[i] < b) System.out.println(b);
else System.out.println(a);
}
}
}
五、紅黑棋(交卷之後五分鐘做出來的,沒有提交,所以不知道A多少)
程式碼
import java.util.Scanner;
public class C {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] list = new int[2 * n];
String color = scanner.next();
for (int i = 0; i < list.length; i++) {
if (color.charAt(i) == 'R') {
list[i] = 1;
} else {
list[i] = -1;
}
}
for (int i = 0; i < list.length; i++) {
list[i] *= scanner.nextInt();
}
scanner.close();
int num = 0;
int r = 1;
int b = -1;
for (int i = 0; i < list.length; i++) {
if (list[i] > 0) {
if (list[i] != r) {
for (int j = i + 1; j < list.length; j++) {
if (list[j] == r) {
num += j - i;
for (int j2 = j; j2 > i; j2--) {
list[j2] = list[j2 - 1];
}
list[j] = r;
break;
}
}
}
r++;
} else {
if (list[i] != b) {
for (int j = i + 1; j < list.length; j++) {
if (list[j] == b) {
num += j - i;
for (int j2 = j; j2 > i; j2--) {
list[j2] = list[j2 - 1];
}
list[j] = b;
break;
}
}
}
b--;
}
}
System.out.println(num);
}
}
相關文章
- 【JAVA】【華為校園招聘筆試-軟體】2020-09-09Java筆試
- 智慧校園全平臺綜合概述與最佳實踐
- 梧桐果:2021屆中國校園招聘報告
- 【深圳】【騰訊廣告】招聘後臺開發工程師工程師
- [深圳][騰訊廣告] 招聘後臺開發工程師工程師
- 騰訊T3團隊整理,騰訊Java校招面試Java面試
- GBASE校園招聘,正式啟動!
- 嗶哩嗶哩校園招聘
- 智慧園區產業園綜合管理平臺解決方案產業
- 智慧園區綜合管理平臺園區管理系統方案
- 基於雲端計算智慧校園綜合解決方案
- 搜狗2012校園招聘自測題
- 2017騰訊Web前端實習生招聘筆試題總結Web前端筆試
- [小米集團校園招聘] 射頻測試工程師 (急招)工程師
- 【小米集團校園招聘】射頻測試工程師 (急招)工程師
- 北森:2021中國企業校園招聘白皮書(附下載)
- 騰訊9.6筆試筆試
- 園區元宇宙:打造智慧園區綜合治理視覺化管理平臺元宇宙視覺化
- 騰訊校招前端開發筆試初試總結| 掘金技術徵文前端筆試
- 智慧園區綜合管理平臺智慧社群解決方案
- 智慧園區綜合管理平臺解決方案有哪些
- 校園交易平臺後臺系統git操作全過程Git
- [小米集團校園招聘] 軟體開發工程師-Java 方向 (急招)工程師Java
- 【小米集團校園招聘】軟體開放工程師-Java 方向 (急招)工程師Java
- 騰訊筆試題集筆試
- [廣州、成都、武漢] 多益網路22屆校園招聘 程式類10+崗位(直通筆試!)筆試
- 園區網部署配置綜合案例
- Java後臺筆記Java筆記
- 校園資訊釋出平臺(清遠大學城)
- 用友&拉勾招聘:2023校園招聘調研報告&備戰攻略(附下載)
- 【面試必備】常見Java面試題大綜合Java面試題
- 從校園到騰訊工作一年的那些跌跌撞撞!
- 【小米集團校園招聘】IoT 軟體專案經理
- [小米集團校園招聘] 嵌入式工程師 (急招)工程師
- [小米集團校園招聘] Android 開發工程師 (急招)Android工程師
- [小米集團校園招聘] iOS 開發工程師 (急招)iOS工程師
- [小米集團校園招聘] IoT 軟體專案經理
- 【小米集團校園招聘】iOS 開發工程師 (急招)iOS工程師