平多多笔试

This commit is contained in:
xiongraorao 2018-08-30 21:03:45 +08:00
parent 0f2e4358ae
commit 2f000929d8
8 changed files with 244 additions and 0 deletions

View File

@ -62,6 +62,7 @@ public class Test {
System.out.println(t[0]);
t[0]= 10;
System.out.println(temp[0]);
}
public int foo() {

View File

@ -0,0 +1,28 @@
package com.raorao.beauty;
/**
* .
*
* @author Xiong Raorao
* @since 2018-08-29-17:36
*/
public class CPU {
public static void main(String[] args) {
int busyTime = 20;
int idleTime = busyTime / 2;
long startTime = 0;
while (true) {
startTime = System.currentTimeMillis();
// busy loop
while ((System.currentTimeMillis() - startTime) <= busyTime)
;
// idle loop
try {
Thread.sleep(idleTime);
} catch (InterruptedException e) {
System.out.println(e);
}
}
}
}

View File

@ -0,0 +1,23 @@
package com.raorao.beauty;
/**
* 数字中1的个数.
*
* @author Xiong Raorao
* @since 2018-08-30-17:28
*/
public class NumOf1 {
public static void main(String[] args) {
System.out.println(count(5));
}
public static int count(int n) {
int sum = 0;
while (n > 0) {
n &= n - 1;
sum++;
}
return sum;
}
}

View File

@ -0,0 +1,42 @@
package com.raorao.interview.pdd.t1;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int hp = Integer.parseInt(scanner.nextLine());
int normal = Integer.parseInt(scanner.nextLine());
int buffer = Integer.parseInt(scanner.nextLine());
int res = process(hp, normal, buffer);
System.out.println(res);
}
private static int process(int hp, int normal, int buffer) {
if (hp <= normal) {
return 1;
}
if (hp <= 2 * normal || hp <= buffer) {
return 2;
}
if (buffer <= normal * 2) {
int count = hp / normal;
if (hp % normal != 0) {
count++;
}
return count;
} else {
int count = 2 * (hp / buffer);
if(hp % buffer != 0){
if (hp % buffer <= normal) {
count++;
} else {
count += 2;
}
}
return count;
}
}
}

View File

@ -0,0 +1,49 @@
package com.raorao.interview.pdd.t2;
import java.util.Scanner;
/**
* .
*
* @author Xiong Raorao
* @since 2018-08-30-20:01
*/
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Main m = new Main();
int N = scanner.nextInt();
int M = scanner.nextInt();
char[][] chessBoard = new char[N][];
for (int i = 0; i < N; i++) {
chessBoard[i] = scanner.next().toCharArray();
}
m.process(chessBoard, N, M);
}
public void process(char[][] chess, int N, int M) {
for (int i = 0; i < M; i++) {
int position = -1;
for (int j = N - 1; j >= 0; j--) {
if (chess[j][i] == 'x') {
position = j;
} else if (chess[j][i] == 'o') {
chess[j][i] = '.';
if (position != -1 && position - 1 >= 0) {
chess[--position][i] = 'o';
}
}
}
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
System.out.print(chess[i][j]);
}
System.out.println();
}
}
}

View File

@ -0,0 +1,37 @@
package com.raorao.interview.pdd.t3;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/**
* .
*
* @author Xiong Raorao
* @since 2018-08-30-19:41
*/
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String[] line1 = scanner.nextLine().split(" ");
int a = Integer.parseInt(line1[0]);
int b = Integer.parseInt(line1[1]);
System.out.println(process(a, b));
}
private static String process(int a, int b) {
List<Integer> list = new ArrayList<>();
while (a != 0) {
a = a % b;
int it = list.indexOf(a);
if (it != -1 && it != list.size() - 1) {
return it + " " + (list.size() - 1 - it);
}
list.add(a);
a *= 10;
}
return list.size() - 1 + " " + 0;
}
}

View File

@ -0,0 +1,61 @@
package com.raorao.interview.pdd.t4;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;
/**
* .
*
* @author Xiong Raorao
* @since 2018-08-30-20:03
*/
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int L = scanner.nextInt();
String[] words = new String[N];
char[][] chars = new char[N][];
for (int i = 0; i < N; i++) {
words[i] = scanner.next();
chars[i] = words[i].toCharArray();
}
List<String> wordList = Arrays.asList(words);
List<PriorityQueue<Character>> cols = new ArrayList<>();
for (int i = 0; i < L; i++) {
PriorityQueue<Character> queue = new PriorityQueue<>();
for (int j = 0; j < N; j++) {
queue.add(chars[j][i]);
}
cols.add(queue);
}
String res = process(wordList, cols, L);
System.out.println(res);
}
private static String process(List<String> words, List<PriorityQueue<Character>> cols,
int length) {
StringBuilder sb = new StringBuilder();
back(sb, words, cols, 0, length);
return sb.toString();
}
private static void back(StringBuilder sb, List<String> words,
List<PriorityQueue<Character>> cols,
int k, int length) {
if (k == length) {
if (words.contains(sb.toString())) {
sb.deleteCharAt(sb.length() - 1);
} else {
return;
}
}
sb.append((char) cols.get(k).poll());
back(sb, words, cols, k + 1, length);
}
}

View File

@ -44,6 +44,9 @@ Java后端开发大数据、分布式应用等
腾讯 | 8.22 | 8.22(新投递) | 电面 | 一面已经挂了<li> 8.28 第二次一面也挂了
Intel | 8.23 | 8.23(新投递) | 电面 | 8.24一面
美团点评 | 8.6 | 8.27 |
唯品会 | | 8.30(实时计算工程师) |
珍爱网 | | 8.30(新投递) |
寒武纪 | 8.30 | 8.30(新投递) |
# 2 复习内容