剑指Offer——好未来视频面知识点储备+面后总结

情景介绍

  • 时间:2016.10.12 13:00-
  • 地点:宿舍
  • 事件:好未来视频面

知识点储备

数据结构

单链表反转

public class ListNode {
    int val;
    ListNode next = null;

    ListNode(int val) {
        this.val = val;
    }
}
    private static ListNode ReverseList(ListNode head) {
        if (head == null)
            return null;
        ListNode reversedHead = null;
        ListNode current = head;
        ListNode pNext = null;
        ListNode pre = null;
        while (current != null) {
            pNext = current.next;
            current.next = pre;
            if (pNext == null)          // 确定反转后的头结点
                reversedHead = current;
            pre = current;
            current = pNext;
        }
        return reversedHead;
    }

合并两个排序的链表

    /**
     *
     * @param ListNode
     *              链表1
     * @param ListNode
     *              链表2
     * @return ListNode
     *              合并后的链表
     */
    private static ListNode Merge(ListNode list1,ListNode list2) {

        // 其中之一为空或均为空
        if(list1 == null || list2 == null){
            return list1 == null?(list2 == null?list1:list2):list1;
        }else{
            ListNode headNode = null;
            if(list1.val < list2.val){
                headNode = list1;
                headNode.next = Merge(list1.next, list2);
            }else{
                headNode = list2;
                headNode.next = Merge(list1, list2.next);
            }
            return headNode;
        }
    }

求两个链表的第一个公共节点问题

private static ListNode FindFirstCommonNode2(ListNode pHead1, ListNode pHead2) {
        // 第一步首先是特殊输入测试,即为空或长度为0的情况,切记!
        if(pHead1 == null || pHead2 == null){
            return null;
        }
        int len1 = getLength(pHead1);
        int len2 = getLength(pHead2);
        int difLen = 0;
        // pHeadTmp1指向较长链表
        ListNode pHeadLong = pHead1;
        // pHeadTmp2指向较短链表
        ListNode pHeadShort = pHead2;
        if(len1 > len2){
            difLen = len1 - len2;
        }else{
            pHeadLong = pHead2;
            pHeadShort = pHead1;
            difLen = len2 - len1;
        }
        // 1.先让长的链表走difLen步
        for(int i = 0; i < difLen; i++){
            pHeadLong = pHeadLong.next;
        }
        // 2.对齐后,两个链表同时走
        while(pHeadLong != null && pHeadShort != null && pHeadLong != pHeadShort){
            pHeadLong = pHeadLong.next;
            pHeadShort = pHeadShort.next;
        }
        return pHeadLong;
    }

    private static int getLength(ListNode pHead){
        int len = 0;
        while(pHead != null){
            len++;
            pHead = pHead.next;
        }
        return len;
    }

多线程

线程与进程的区别

实现生产者、消费者

package cn.edu.ujn.producer_customer;

// 公共资源类
class PublicResource {

    private static final int MAX_RESOURCE_NUMBER = 10;
    private int number = 0;    

    /**
     * 增加公共资源
     */
    public synchronized void increace() {
        while (number > MAX_RESOURCE_NUMBER) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        // 添加资源
        number++;
        System.out.println(number);
        // 进行通知
        notify();
    }    

    /**
     * 减少公共资源
     */
    public synchronized void decreace() {
        while (number == 0) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        number--;
        System.out.println(number);
        notify();
    }
}

// 生产者线程,负责生产公共资源
class ProducerThread implements Runnable {
    private PublicResource resource;    

    public ProducerThread(PublicResource resource) {
        this.resource = resource;
    }    

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep((long) (Math.random() * 1000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            resource.increace();
        }
    }
}    

// 消费者线程,负责消费公共资源
class ConsumerThread implements Runnable {
    private PublicResource resource;    

    public ConsumerThread(PublicResource resource) {
        this.resource = resource;
    }    

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep((long) (Math.random() * 1000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            resource.decreace();
        }
    }
}    

public class ProducerConsumerTest {
    public static void main(String[] args) {
        PublicResource resource = new PublicResource();
        new Thread(new ProducerThread(resource)).start();
        new Thread(new ConsumerThread(resource)).start();
        new Thread(new ProducerThread(resource)).start();
        new Thread(new ConsumerThread(resource)).start();
        new Thread(new ProducerThread(resource)).start();
        new Thread(new ConsumerThread(resource)).start();
    }
}    

多线程发短信

设计模式

观察者设计模式

单例模式

简单工厂

工厂方法

抽象工厂设计模式

代理设计模式

动态代理设计模式

排序

快排

归并排序

查找

二分查找

存储

堆栈区别

算法

克鲁斯卡尔算法

J2EE

对Spring中IOC、AOP的理解

面后总结

  • 1.数据库索引(聚集索引、组合、主键、普通、唯一)
  • 2.select * from db_name where name=’demo’order by age group by age;执行顺序。
  • 3.提高数据库查询效率的措施。
  • 4.基本数据类型 int、long、short、float、double、char、boolean、byte
  • 5.float与double的区别:精度不同。
  • 6.冒泡排序、快速排序;

  数据库这一块自己是完败!自己只是用了mysql,但是对于里面的概念自己真的表示无能为力!其中数据库索引这一块,其实在项目开发中,自己也没有使用到。惭愧无比!但是简历中明明写了熟悉SQL语句、存储过程和函数(从第二道问题中就完全推翻了自己。)。不能使之成为自己的鸡肋!

 Mysql语法顺序,即当sql中存在下面的关键字时,它们要保持这样的顺序:

  • select[distinct]、from、join(如left join)、on、where、group by、having、union、order by、limit

  Mysql执行顺序,即在执行时sql按照下面的顺序进行执行:

  • from、on、join、where、group by、having、select、distinct、 union、order by

  group by要和聚合函数一起使用,例如:

  • select a.Customer,sum(a.OrderPrice) from orders a where a.Customer=’Bush’ or a.Customer = ‘Adams’ group by a.Customer
  • 数据库+Java是自己找工作的双翼。

  通过面试,还可以发现的问题就是自己的简历中项目过少,导致面试官关于项目的面试中,所问的问题不会太多(这是面试官反映的)。但是,自己感觉也只有“立马送药”这个项目可以拿得出手,其他的项目只可说是练习项目,例如“鲜花礼品网”、“CTCs监测系统”、“竞彩APP”。

  另外,如果视频面的话,最好戴耳麦,否则会很尴尬的。自己当时就没有戴耳麦,结果说话时音调稍不均匀,就会带来很大的噪声与回音,严重影响了面试质量。第一次视频面,姑且作为教训。

  最后可以问面试官问题,最恰当的问题莫过于“请评价一下我此次的视频面,还欠缺哪方面的知识储备,面试结果何时可以给出”。

  最后,自己给自己的面试评分为55。





最新文章

  1. 在Ubuntu 16.10安装mysql workbench报未安装软件包 libpng12-0错误
  2. iOS系列 基础篇 05 视图鼻祖 - UIView
  3. Ceph RGW服务 使用s3 java sdk 分片文件上传API 报‘SignatureDoesNotMatch’ 异常的定位及规避方案
  4. maven中央仓库访问速度太慢的解决办法
  5. 【转载】 Android PullToRefresh (ListView GridView 下拉刷新) 使用详解
  6. SQL中 将同一个表中的A列更新到B列,B列更新到A列
  7. MDI窗体容器 权限设置
  8. C# 线程同步
  9. 从0开始学Java——@override的作用
  10. iOS开发——使用技术OC篇&amp;简单九宫格锁屏功能的实现与封装
  11. Velocity - 单例还是非单例
  12. 简单讨论数据类型(byte)强制转化后的数值变化规律
  13. Asp.net Role manager tutorial
  14. dirname
  15. 设置vs环境
  16. 硬杠后端(后端坑系列)——Django前期工作
  17. UWP 多语言的三个概念
  18. STlinkSWD模式连线方式
  19. Bower使用笔记
  20. sublime Text 些许使用配置

热门文章

  1. hibernate--CRUD初体验
  2. [USACO 09FEB]Fair Shuttle
  3. 洛谷mNOIP模拟赛Day2-将军令
  4. [洛谷]P3613 睡觉困难综合征
  5. [NOI2011]
  6. 什么是spool系统,什么是预输入,什么是缓输出?
  7. mysql中binlog与存储引擎的2PC
  8. Linked List Cycle II--寻找单链表中环的起始点
  9. SpringBoot 使用MultipartFile上传文件相关问题解决方案
  10. Oracle10g以上sysaux表空间的维护和清理