pdd笔试Java 全部AC



public class Main1 {  static HashMap<Integer, Integer> map;  static int[] res;  public static void main(String[] args) {
        Scanner in = new Scanner(System.in);  int n = in.nextInt();  int k = in.nextInt();  map = new HashMap<>(); int max = 0; for (int i = 0; i < n; i++) {  int tmin = in.nextInt(); int tmax = in.nextInt(); map.put(tmin, map.getOrDefault(tmin, 0) + 1); map.put(tmax + 1, map.getOrDefault(tmax + 1, 0) - 1);
            max = Math.max(max, tmax + 1);
        } res = new int[102]; //-50 -- +50    int sum = 0; int start = -1; int end = -1; for (int i = 0 ; i <= 101; i++) {
            sum += map.getOrDefault(i - 50, 0); res[i] = sum; if (sum >= k && start == -1) {
                start = i - 50;
            } else if (sum >= k && start != -1 && i != 101){
                end = i - 50;
            }
        } if (start != -1 && end != -1) {
            System.out.println(start + " " + end);
        } else {
            System.out.println("error");
        }
    }
}
public class Main2 {  public static void main(String[] args) {
        Scanner in = new Scanner(System.in);  String[] time = in.next().split(":");  double min = Double.parseDouble(time[1]); double hour = Double.parseDouble(time[0]) % 12; double diff = Math.abs(5.5 * min - 30 * hour);
        DecimalFormat df = new DecimalFormat("##.#");
        diff = diff > 180 ? 360 - diff : diff;
        System.out.println(df.format(diff));
    }
}
public class Main3 { static int[] x; static int[] y; public static void main(String[] args) {
        Scanner in = new Scanner(System.in); int n = in.nextInt(); x = new int[n]; y = new int[n]; int count = 0; for (int i = 0; i < n; i++) { x[i] = in.nextInt(); y[i] = in.nextInt(); for (int j = 1; j < i; j++) { for (int k = 0; k < j; k++) { if (det(x[i], y[i], x[j], y[j], x[k], y[k]) == 0) { continue;
                    } else {
                        count++;
                    }
                }
            }
        }
        System.out.println(count);
    } private static int det(int x1, int y1, int x2, int y2, int x3, int y3) { return x1 * (y2 - y3) - y1 * (x2 - x3) + 1 * (x2 * y3 - y2 * x3);
    }
}
public class Main4 { public static void main(String[] args) {
        Scanner in = new Scanner(System.in); int n = in.nextInt(); int k = in.nextInt(); int[] res = new int[n];
        Deque<Integer> max = new ArrayDeque<>();
        Deque<Integer> min = new ArrayDeque<>();
        StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) {
            res[i] = in.nextInt(); while (!max.isEmpty() && max.peek() < i - k + 1) {
                max.poll();
            } while (!max.isEmpty() && res[max.peekLast()] < res[i]) {
                max.pollLast();
            }
            max.offer(i); while (!min.isEmpty() && min.peek() < i - k + 1) {
                min.poll();
            } while (!min.isEmpty() && res[min.peekLast()] > res[i]) {
                min.pollLast();
            }
            max.offer(i);
            min.offer(i); if (i >= k - 1) { int diff = res[max.peek()] - res[min.peek()];
                sb.append(diff + " ");
            }
        }
        System.out.println(sb.toString().trim());
    }
}

顺序记不清了 第一个是温度计 第二个是时间角度 第三个是三角形 第四个是滑窗

#笔试题目#
全部评论
实验室大佬也AK了,好像没啥用,挺多人都全做出来了/给跪了
点赞 回复 分享
发布于 2018-04-04 21:42
第一题有考虑区间不连续,比如[1,2,3][5,6]取[1,2,3]这个区间吗?
点赞 回复 分享
发布于 2018-04-04 21:13
可否调一下上传格式,这样看着好别扭~
点赞 回复 分享
发布于 2018-04-03 19:03
可以说是很牛逼了
点赞 回复 分享
发布于 2018-04-03 18:21

相关推荐

bg双非本科,方向是嵌入式。这次秋招一共拿到了&nbsp;8&nbsp;个&nbsp;offer,最高年包&nbsp;40w,中间也有一段在海康的实习经历,还有几次国家级竞赛。写这篇不是想证明什么,只是想把自己走过的这条路,尽量讲清楚一点,给同样背景的人一个参考。一、我一开始也很迷茫刚决定走嵌入式的时候,其实并没有一个特别清晰的规划。网上的信息很零散,有人说一定要懂底层,有人说项目更重要,也有人建议直接转方向。很多时候都是在怀疑:1.自己这种背景到底有没有机会2.现在学的东西到底有没有用3.是不是已经开始晚了这些问题,我当时一个都没答案。二、现在回头看,我主要做对了这几件事第一,方向尽早确定,但不把自己锁死。我比较早就确定了嵌入式这个大方向,但具体做哪一块,是在项目、竞赛和实习中慢慢调整的,而不是一开始就给自己下结论。第二,用项目和竞赛去“证明能力”,而不是堆技术名词。我不会刻意追求学得多全面,而是确保自己参与的每个项目,都能讲清楚:我负责了什么、遇到了什么问题、最后是怎么解决的。第三,尽早接触真实的工程环境。在海康实习的那段时间,对我触动挺大的。我开始意识到,企业更看重的是代码结构、逻辑清晰度,以及你能不能把事情说清楚,而不只是会不会某个知识点。第四,把秋招当成一个需要长期迭代的过程。简历不是一次写完的,面试表现也不是一次就到位的。我会在每次面试后复盘哪些问题没答好,再针对性补。三、我踩过的一些坑现在看也挺典型的:1.一开始在底层细节上纠结太久,投入产出比不高2.做过项目,但前期不会总结,导致面试表达吃亏3.早期有点害怕面试,准备不充分就去投这些弯路走过之后,才慢慢找到节奏。四、给和我背景相似的人一点建议如果你也是双非,准备走嵌入式,我觉得有几件事挺重要的:1.不用等“准备得差不多了”再投2.项目一定要能讲清楚,而不是做完就算3.不要只盯着技术,多关注表达和逻辑很多时候,差的不是能力,而是呈现方式。五、写在最后这篇总结不是标准答案,只是我个人的一次复盘。后面我会陆续把自己在嵌入式学习、竞赛、实习和秋招中的一些真实经验拆开来讲,希望能对后来的人有点帮助。如果你正好也在这条路上,希望你能少走一点弯路。
x_y_z1:蹲个后续
点赞 评论 收藏
分享
评论
4
14
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务