找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 13428|回复: 28
收起左侧

[米群网大牛独家面经总结] 帮人发几个面经

  [复制链接]
发表于 12-5-2014 02:19 PM | 显示全部楼层 |阅读模式

亲!马上注册或者登录会查看更多内容!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
声明: 我是帮人发的,顺便感谢下提供资源的人~~

5 A$ v1 W5 j9 d' Z
Google:
4 ~" m" J4 x: o
Please use this Google docto code during your interview. To free your hands for coding, we recommend thatyou use a headset or a phone with speaker option.
: z3 W( W- \4 W" G: F
. s0 [6 q3 B$ J. K7 D, K2 W

% k9 c% j" k: i. B8 Z
public class Foo {
   private final int i;
   private final String s;
   public Foo (...)
   public int hashcode() {
       returni * s.length();
   }
   public booleanequals(Object f) {
       returnf != null && f instanceof(Foo) && this.i == ((Foo) f).getI()&& s.equals(((Foo) f).getS());
   }
}

( P8 L8 v# q( W8 q
Iterable<String> lines
public List<String>getNonDuplicateLines(List<String> lines) {
   Map<String, Integer>map = new HashMap<String, Integer>();
   for(String s : lines) {
       if(!map.containsKey(s))
           map.put(s,1);
       else
           map.put(s,map.get(s) + 1);
   }
   Set<String> keySet =map.keySet();
   List<String> result =new ArrayList<String>();
   for(String key, keySet) {
       if(map.get(key)== 1) {
           result.add(key);
       }
   }
   return result;
}

1 ~' J% b1 D; f& Z$ V8 b
Find the number of occurrences of a value ina sorted array of ints.
. g0 H" w0 |" H8 n* ~' T
1,1,2,2,2,3,4,5,5
public int findOccurrences(int[] arr, target){
   int left = -1;
   int right = -1;
   int low = 0, high =arr.length - 1;
   int pivot = -1;
   while(low <= high) {
       intmid = low + (high - low) / 2;
       if(arr[mid]== target) {
           pivot= mid;
           break;
       }
       elseif(arr[mid] < target)
           low= mid + 1;
       else
           high= mid - 1;
   }
   if(pivot == -1)
       return0;
   left = right = pivot;
   low = 0, high = pivot - 1;
   while(low <= high) {
       if(arr[high]< target)
           break;
       intmid = low + (high - low) / 2;
       if(target<= arr[mid]) {
           if(target== arr[mid]) {
               left= mid;
           }
           high= mid - 1;
       }
       else{
           low= mid + 1;
       }
   }
   low = pivot + 1;
   high = arr.length - 1;
   while(low <= high) {
       if(arr[low]> target)
           break;
       intmid = low + (high - low) / 2;
       if(target>= arr[mid]) {
           if(target== arr[mid])
                right= mid;
           low= mid + 1;
       }
       else
           high= mid - 1;
   }
   return right - left + 1;
}
Google
llease use thisGoogle doc to code during your interview. To make hands free coding a littleeasier, we recommend that you use a headset or a phone with speaker option.
) x: F/ h0 z  C$ O! O2 i3 B5 B
3 N* I9 Z2 F$ U& |  hBest,
5 G( j7 C) ]" X5 hGoogle Staffing% ~- f$ {* _) G9 `' e
4 X( r/ ?2 G3 R: E0 I

8 u/ f# Q* y7 R% A: B. b1 X+ ~8 Z& |8 H$ j, d. S

& s; P( ?. |" ?6 _& t( E4 P' ~# @
Leaderboard
1  A  50000
2  B  45000
3  C    3000
Player {
            Name;
            score
}
getByRank();
updateByName();
//a^b
public double pow(int a, int b) {
            if(b== 0) {
                        return1;
} else if(a == 0){
            return 0;
} else {
            if(b < 0) {
                        if(b >Integer.MIN_VALUE) {
                                    } else {
            return (double)1 / pow(a, -b); // (1<< 31) - 1; (1 << 31)
return(double)1 / pow(a, Integer.MAX_VALUE) / a;
}
}else {
            double half = pow(a, b / 2);
            double res = half * half;
            if(b % 2 == 1) {
                        res *= a;
}
returnres;
}
}
}
time : O(lg b)
[0, 3, 1, 2, 0, 0, 5] -> [3, 1, 2, 5, 0,0, 0]
private void swap(int[] num, int p, int q) {
            if(p!= q) {
                        inttmp = num[p];
                        num[p]= num[q];
                        num[q]= tmp;
}
}
public void solve(int[] num) {
            if(num== null || num.length == 0) {
                        return;
}
int cur = 0;
int end = 0;
while(cur <num.length) {
            if(num[cur] != 0) { // 0, 3, 1, 2,0,0, 5
                        swap(num, cur ++, end++) // cur, end: 2, 1; 3,2; 4, 3; 7, 4
}else {
            ++ cur; // 1, 5, 6
}
}
}
[3, 0, 1]

( `4 H1 Y6 v4 Y8 L% y0 d! p* a2 F' l. @' \, t) @7 j
Facebook:
Phone number combination
# X2 }* r. p5 _0 \( \  n. C8 F
Linkedin:
Flip binary tree
Max subarray sum/ product
% S5 {4 |2 F: Q8 Q7 ?
: Z. e3 D2 Y6 G$ P: M
0 Y. g% [- k6 O
Linkedin Onsite
1.    Manager: 项目介绍 极其详细
2.    Design: Amazon Product Webpage
3.    Coding: House Painting + followup
Max Points
4.    Coding: Minimum Window
Sqrt (Double)

- d1 _- Y- K+ x: R9 K
' L7 j$ D! q" q3 u" ^5 g# `
Hulu Phone
Helo, Xiao!

1 A4 K1 G8 W% q
RANSOM NOTE
/ B# d" F4 I0 C1 g9 `9 g. U
- Someone wants to send amessage, but they do not want to give away their handwriting
- So they have a message,and they cut out letters in a magazine to make the message
1 b4 x2 s3 W  V! N$ F' J3 [
message: "Give me1000 dollars"
magazine: "My name isgiven to be today 10000 dollar"
8 c. o: N. X' a, P
Want to write a message,by cutting out letters in a magzine.
6 v, n/ J- w: R: [: C! a* @
- does the magazinecontain enough of the letters from my message
3 q. o' e& u. P1 j1 u) I, v) i
// returns true when thereare enough letters in the magazine to make the message
// assume all uppercase
// ignore punctuation

5 T# W: Q+ {+ U7 ~) r& C
private voidplusOne(Map<Character, Integer> map, char key) {
   map.put(key, map.containsKey(key) ? map.get(key) + 1 : 1);
}
$ U( v! R5 i3 z/ A! y! Z4 I8 p7 T# ~
private voidreduceOne(Map<Character, Integer> map, char key) {
   if(map.get(key) == 1) { map.remove(key); }
    else {map.put(key, map.get(key) - 1);
}
# S7 L" P. P( Z& b* n2 {& O
public booleancanCreateRansomNote(String message, String magazine) {
    Map<Character, Integer> table = newHashMap<Character, Integer>();
    for(inti = 0; i < message.length(); ++ i) {
       plusOne(table, message.charAt(i));
    }
    for(inti = 0; i < magazine.length() && !map.isEmpty(); ++ i) {
       char c = magazine.charAt(i);
       if(map.containsKey(c)) { reduceOne(map, c); }
    }
    returnmap.isEmpty();
}

! G& h- B4 ~, N' ]* K
CHEMiCAL EQUATION PARSING

1 F$ f( X  a; C% D* T+ s# D6 l
H20 - {H: 2, O: 1} -["H", "2", "O"]
/ Z2 u& i9 ^; M* m
NaCl - {Na: 1, Cl: 1} -["Na", "Cl"]
& d* \+ L4 n* _1 o8 l( Z9 a
O(H(UO)2)3 - {O: 7, H: 3} -["O", "(", "H", "(", "O","2", ")", "3"]
# ~! R- ~/ w& x: T2 o
O(H(C)) - {O: 1, H: 1,C:1} - ["O", "(", "H", "(","C", ")", ")"]
! z1 T7 s, T7 h6 a0 C1 ^, [; `
- Always well-formed input
- Tokens will be one of:
    -Element
    -Number
    - Leftparen "("
    - Rightparen "("

4 m6 L5 W4 X* x) G/ @
private voidadd(Map<String, Integer> map, String key, int val) {
   if(!map.containsKey(key)) { map.put(key, val); }
    else {map.put(key, map.get(key) + val);
}

6 T5 `( o# S- p* ]) a
private booleanisInteger(String s) {
    try {
       Integer.parseInt(s);
    }catch(NumberFormatException e) {
       return false;
   }      
    returntrue;
}
0 g: G4 p" K- z/ D" T* w
H20

0 Z2 k8 b: u, c
i = 0
res: {H: 2}

+ i3 X% r* X/ d% g3 o
Map<String, Integer>parseEquation(String[] eq) {
   Map<String, Integer> res = new HashMap<String, Integer>();
    Stack<Map<String,Integer>> mapStack = new Stack<Map<String, Integer>>();
   mapStack.push(res);
    for(inti = 0; i < eq.length; ++ i) {
       String cur = eq【i】;
       if(cur.equals("(")) {
           mapStack.push(new HashMap<String, Integer>());
       } else if(cur.equals(")")) {
           int k = 1;
           if(i < eq.length - 1 && isInteger(eq[i + 1])) {
               k = Integer.valueOf(eq[i + 1]);
               ++ i;
           }
           Map<String, Integer> currMap = mapStack.pop();
           Map<String, Integer> prevMap = mapStack.peek();
           for(Map.Entry<String, Integer> entry : currMap.entrySet()) {
               add(prevMap, entry.getKey(), entry.getValue() * k);
           }
       } else if(i < eq.length - 1 && isInteger(eq[i + 1])) {
           add(mapStack.peek(), cur, Integer.parseInt(eq[i + 1]));
           ++ i;
       } else {
           add(mapStack.peek(), cur, 1);
       }
    }
    returnres;
}

. A6 g. {, c5 `" X1 Q/ d  D
Linkedin 加面:
public final class MapPruner
{
  /**
  * Prune a map byremoving entries corresponding to the given paths.
  * Example:
  * input:
  * {
  *   "key1": "bar",
  *   "key2": "baz"
  *   "key3":
  *   {
  *     "key4": "bar"
  *   }
  *  }
  *
  * pathsToPrune:["key2", "key3/key4"]
  *
  * output:
  * {
  *   "key1": "bar",
  *   "key3":
  *   {
  *   }
  * }
  */
+ l/ ^/ t- r' {9 V. u1 Y) L0 O
//  pathsToPrune = ["" ]
" M( B; X( U9 Y) [. |0 u* s
  private static voidhelper(String[] strs, int i, Map<String, Object> map) { // i = 1; Map:{key4 : bar}
     if(!map.containsKey(strs【i】)) { return; }
      Object val =map.get(strs【i】); // baz; {key4: bar}; bar
      if(i ==strs.length - 1) { map.remove(strs【i】); } // remove baz
      else if(valinstanceof Map) { // true
          helper(strs,i + 1, (Map)val);
      }
  }

( V" v* W; ?( u# K
  public staticMap<String, Object> pruneByPaths(
    finalMap<String, Object> input,
    finalCollection<String> pathsToPrune)
  {
      if(input == null|| pathsToPrune == null) {
          throw newIllegalArgumentException("Error Msg");
      }
      for(String path: pathsToPrune) { // key2 ; key3/key4
          if(path !=null && !path.equals("")) {
              String[]strs = path.split("/"); // {key2}; [key3, key4]
             if(strs.length > 0) { // 2
                 helper(strs, 0, input);
              }
          }
      }
      return input;
  }

6 F( d7 W) o, J2 B. I- h1 M) k# `6 O2 m! V5 l

' V% C( d0 D0 \6 k( Z) e  @4 s4 a7 J7 i
FB:
* ]0 ]* `: Q, O- i5 @% _8 yFacebook onsite一周,HR说明天约电话,好紧张。面经
% D& {/ d- D7 G+ N* }6 P( f3 M1. Word Break.8 m" X$ v! D& C
2. Merge K sorted list- g* @1 n# b/ A( v! v2 r
3. Word Search(可以斜着走)+ w7 F" c# a+ a2 y7 J
* c& W- r9 D7 _% h% b2 P1 A

# I+ r6 P3 B4 t7 R* i3 U* `$ U% N2 u+ S% s3 U+ h. N" n
Youtube
1.    视屏推荐的方式; 算法:wildcard match(Leetcode)
2.    一些数据结构概念
给一个String 可以包含数字或者字母 找出里面的是否存在一个substring全是数字而且这个substring表示的数字可以被36整除,并且不能是0。
e.g.: 360ab: True
                  0ab: False
3.    给一堆range(未order有重叠) 然后给一个数 判断这个数是否在range里面
(1,  5)(0,8)(4,6)
9: false
2: true
可以用bitset做
然后衍生出merge interval算法coding,再用bynarysearch找target是否在range中
4.    Pascal Triangle
0 ]3 @8 O7 I! w# Q4 V/ l% e

8 Q1 ]( D$ ^5 u* Y6 b
HULU onsite
1.    Recover dictionary order
2.    ATM Database system design (Withdraw,deposit and check balance)
3.    Minimum window
4.    Sliding window for one function only call atmost 3 times in 5 minutes.
! R: g( H( `+ g- C

- W( Y; [4 k0 U* D& J

本帖被以下淘专辑推荐:

我们始终相信IT会持续改造甚至创新传统行业,我们始终全面看好咱们的CS专业!

2

主题

2

精华

277

积分

高级会员

Rank: 3Rank: 3

积分
277
发表于 12-7-2014 08:54 AM | 显示全部楼层
ym caobosi~~~

18

主题

6

精华

257

积分

高级会员

Rank: 3Rank: 3

积分
257
发表于 12-7-2014 12:06 PM 来自美国米群网手机版 | 显示全部楼层
太赞了!!!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表