- 自我介绍
- c++用的多吗? (后来才知道组里主要用c++开发的)
- 说说hive和mysql有什么区别? 应用场景有什么区别? hive和mysql在执行SQL的时候流程上有什么区别?
- 数据倾斜了解吗? 解释一下
- hdfs上的有哪些压缩格式? 说一说他们的区别. (我只用过lzo压缩, 并且不知道原理)
- hive会把所有的SQL都转化为mapreduce吗? (这里感觉面试官觉得我hive掌握的一般, 就没接着问下去了)
- 说一下mysql 聚集索引和非聚集索引区别?
- 哪些情况下使用聚集索引效率高, 哪些情况下使用非聚集索引比较高?
- 讲一讲联合索引最左结合的规则吧
- 假如有一个联合索引(a, b), where条件里面写成
b = value_b and a = value_a
这样可以走联合索引吗? (之前没考虑过这个问题, 但是肯定能啊, 假如这点都做不到也太不智能了吧)
- 说说jdk1.7和jdk1.8里面的ConcurrentHashMap结构有什么区别?
- 说说ConcurrentHashMap里面的加锁类型有哪些?
- 讲一讲CAS的原理?
- 说一说使用线程池带来的优点? (线程复用, 方便管理)
- 你刚才说到了创建和销毁线程的开销很大, 那你来说说开销都花费在了什么地方? 这里我只回答了系统调用产生的开销和内存分配产生的开销.
- 你刚才说到了内存分配, 具体分配了哪些内存呢? (线程控制块, 栈内存)
- 你刚才说到了线程控制块, 这个数据结构存放在哪里呢? (我回答的是存储在进程的文本区里, 后面听录音才发现错了, 当时脑子真的抽风了, 明显应该是分配在OS的内核空间里的啊, 这个错误犯的太低级了!)
- redis为什么采用单线程? (CPU不是瓶颈)
- 你刚才说到执行bgsave命令的时候redis不是单进程, 他创造出来的子进程也是用fork创建的吗?
- 说一下redis 分布式锁? (set nx ex ,redlock)
- 讲讲c++多态实现原理?
编程题, 链表之和.
很简单对吧, 我一开始也是这么想的. 但是最后没a出来. 😭
分三个操作, 前导0清除, 链表反转, 链表相加.
问题出在链表反转这里了. while判断条件退出的过于早了. 还是细节掌握的不行.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
| import java.util.Scanner; class Node{ int val; Node next; Node(int val, Node next){ this.val = val; this.next = next; } Node(){ this(0,null); } Node(int val){ this(val,null); } public String toString(){ String ans = ""; for(Node i = this; i != null; i = i.next){ ans += i.val; } return ans; } } public class Main { public static Node reverse(Node head){ if(head == null || head.next == null){ return head; } Node dummyHead = new Node(-1, head); Node p1 = dummyHead.next; Node p2 = dummyHead.next.next; while(p2.next != null){ Node tmp = p2.next; p2.next = p1; p1 = p2; p2 = tmp; } Node newTail = dummyHead.next; Node newHead = p2; dummyHead.next = newHead; newTail.next = null; return dummyHead.next; } public static Node removeLeadingZero(Node a){ if(a == null || a.next == null){ return a; } for(Node i = a; i != null; i = i.next){ if(i.val != 0){ return i; } } return new Node(0,null); } public static Node add(Node a, Node b){ if(a == null || b == null){ throw new NullPointerException(); } a = removeLeadingZero(a); b = removeLeadingZero(b); Node reverse_a = reverse(a); Node reverse_b = reverse(b); Node ai = reverse_a; Node bi = reverse_b; int carry = 0; Node resultList = new Node(-1,null); Node resultListTail = resultList; while(ai != null || bi != null){ int value_a = (ai == null) ? 0 : ai.val; int value_b = (bi == null) ? 0 : bi.val; int tmp = (value_a + value_b + carry); int result = tmp % 10; carry = tmp / 10; resultListTail.next = new Node(result, null); resultListTail = resultListTail.next; ai = (ai == null) ? null : ai.next; bi = (bi == null) ? null : bi.next; } if(carry >= 1){ resultListTail.next = new Node(carry, null); resultListTail = resultListTail.next; } return removeLeadingZero(reverse(resultList.next)); } public static void main(String[] args){ Node a = new Node(4); Node aa = new Node(3,a); Node aaa = new Node(2,aa); Node aaaa = new Node(1, aaa); Node list_a = new Node(0,aaaa); Node b = new Node(9); Node bb = new Node(8,b); Node bbb = new Node(7,bb); Node list_b = new Node(0,bbb); System.out.println(reverse(removeLeadingZero(list_b))); System.out.println(add(list_a, list_b)); } }
|