注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号 
x
攒人品 助各位新年offer多多
1. Integer to English word
>
2. findFirstBugCommit (binary search)
>
```
二分法的变种,看一下正常的二分法,找第一个,找最后一个
```
3. binary string相加 (^ ^ ^)
>
4. alien dictionary (Map<Character, Set<Character>> BFS)
```java
public String alienOrder(String[] words) {
Map<Character, Set<Character>> map=new HashMap<Character, Set<Character>>();
Map<Character, Integer> degree=new HashMap<Character, Integer>();
String result="";
if(words==null || words.length==0) return result;
for(String s: words){
for(char c: s.toCharArray()){
degree.put(c,0);
}
}
for(int i=0; i<words.length-1; i++){
String cur=words[i];
String next=words[i+1];
int length=Math.min(cur.length(), next.length());
for(int j=0; j<length; j++){
char c1=cur.charAt(j);
char c2=next.charAt(j);
if(c1!=c2){
Set<Character> set=new HashSet<Character>();
if(map.containsKey(c1)) set=map.get(c1);
if(!set.contains(c2)){
set.add(c2);
map.put(c1, set);
degree.put(c2, degree.get(c2)+1);
}
break;
}
}
}
Queue<Character> q=new LinkedList<Character>();
for(char c: degree.keySet()){
if(degree.get(c)==0) q.add(c);
}
while(!q.isEmpty()){
char c=q.remove();
result+=c;
if(map.containsKey(c)){
f题 给一段html,查询其中一个节点,并且按要求print位置信息。.1point3acres网
比如说 <html>. 围观我们 3 acres
<body><node><node><body>
<node><node>
<html>
. 1point3acres
查询node的话打印两条字符串,0:html->0:body->0:node和0:html->1:node
第二题给一串括号,用树的形式表示出来
85. Letter Combinations of a Phone Number
86. 给两个没有duplicate element的sorted list, 找到公共元素
followup1: 如果有duplicate,只需要存一个
followup2: 如果其中一个list特别长,没有duplicate
followup3: 如果其中一个list特别长,有duplicate,所有duplicate都要存下来
87.622. Design Circular Queue
88. 282. Expression Add Operators
89. post order
90.10. Regular Expression Matching
91. 题目是给一个binary tree,在tree上装camera,每一个camera能够监视到parent,自己和两个子节点。问最少安装多少个camera。
Resulttype(include root / without including root (minimum))
92. 新题是
class IOBuf {
char[] data;
int length;
IOBuf next;
}
匹配俩个list的内容是否一样
比如list: [h,e] -> [l, l, o] -> null 和 [h,e,l] -> [l, o] -> null return true
注意data可以为null, length可以为0:
[h,e] -> [l, l, o] -> [] -> [] -> null 和 [h,e,l] -> [l, o] -> null return true
93. Intersection of Two Arrays II
|